>_ IzzyLab

Hands-on task

This task is step 8 of the course “Encodings and checksums”

Decode and verify integrity

medium~10 min

The file /root/blob.b64 is data in base64. Decode it into /root/blob.bin, compute the SHA-256, and compare it with the expected hash from /root/blob.sha (the file came as is — there may be extra spaces after the hash). Write MATCH or DIFF to /root/verdict.txt.

What you'll practise:
  • base64
  • sha256sum
  • integrity verification
  • string comparison
  • bash conditionals

Topic breakdown

A typical integrity check of a transferred file consists of three steps: first the data is decoded (here from base64), then its hash is computed (sha256sum gives the hash plus the name — the name has to be stripped), then the resulting hash is compared with the reference one. The verdict is written based on the string comparison result. The catch is the extra spaces and newline that easily end up in the variable when reading the hash from a file and break the comparison.

What's checked

  1. base64 decoded into blob.bin
  2. the verdict matches the hash comparison

What it looks like