What you will prove
The bytes you have either match a recorded digest or they do not.
SHA-256 reads bytes. A changed word, line ending, encoding, or final newline changes
the result. This exercise fixes all of those inputs with two downloadable UTF-8 files.
Step 1
Download all three files into one directory.
Both text fixtures use UTF-8, LF line endings, and one final newline. The checker calls
read_bytes(), so it does not translate text or line endings before hashing.
Step 2
Confirm the original file.
python check_sha256.py e079f56bca7a9447e85e311560f561c44184164e55cc6555f365ee4aa2a06faf original.txt
file: original.txt
expected: e079f56bca7a9447e85e311560f561c44184164e55cc6555f365ee4aa2a06faf
actual: e079f56bca7a9447e85e311560f561c44184164e55cc6555f365ee4aa2a06faf
result: MATCH
The checker exits with status 0 when the two digests are equal.
Step 3
Use the same expected digest against the changed file.
python check_sha256.py e079f56bca7a9447e85e311560f561c44184164e55cc6555f365ee4aa2a06faf changed.txt
file: changed.txt
expected: e079f56bca7a9447e85e311560f561c44184164e55cc6555f365ee4aa2a06faf
actual: 70e1c149e4359d34bc23e7c182d63a21f0accbb340832898b1c9ca205e24158d
result: MISMATCH
The checker exits with status 1. That failure is the useful result: it catches that
changed.txt is not byte-for-byte identical to the recorded input.
Boundary
Equality is a narrow claim.
A matching digest is strong evidence that the checked bytes equal the bytes behind
the expected digest. It does not show who created the file, whether the expected
digest came from a trusted source, whether the content is true, or whether the code
is safe or correct. Record the digest and its source together.
Troubleshooting
When your result differs
- Confirm the filename and the 64-character expected digest.
- Download the fixture rather than copying it through an editor that may change line endings.
- On Windows, try
py check_sha256.py ... if python is not available. - A mismatch should stay a failure until you can explain the changed bytes.
Next step
Move from one digest check to the wider evidence model: what is runnable, build-recorded, attested, or still absent.