HackBlue

Tools · Cryptography and passwords in practice · 21 / 24

A SHA-256 digest is not the file

A SHA-256 hex string is the digest of the bytes you hashed. It is not those bytes, and it does not name a path you did not include. Write the path and the digest together.

9 min read · practice only with authorization

The hex is the digest

When a hash command finishes, it prints a digest. For SHA-256 that digest is 32 bytes, often written as hex. The digest is the function’s output. Opening it in an editor does not show the file.

The same digest means the same bytes were hashed, for this function. It does not say who hashed them, and it does not say the path unless you wrote the path down.

The path is a separate fact

A checksum line that includes a filename names that filename as the operator recorded it. If you only saved the hex, write “path not recorded.” Do not attach the digest to a different file because the names look similar.

A second file is a second hash. Do not copy the first digest onto it.

What to write down

File the algorithm name, the digest, and the path you hashed. If you compared two digests, say whether they matched. A match is about those two inputs. It is not a signature and not an owner.

Lab: a digest read as the document

A lab note stores only the hex digest of notes.txt. A draft pastes that hex into the report as the document text, and also says backup.txt has the same contents because it was in the same folder.

The note says the hex is the SHA-256 digest and the path was notes.txt. The document text is whatever is in that file, which the hex is not. backup.txt was not hashed, so it is not given this digest.

Snippet
algorithm: SHA-256
path: notes.txt
digest: recorded hex
backup.txt: not hashed
write: digest of notes.txt
not: the hex is the document, and not backup.txt

Diagram

The digest and the bytes

The hex identifies an input you named. It is not the input.

Digest

Is. The hash output

Matches. Another digest of the same bytes

Does not. Display the file or name an unhashed path

The file

Is. The bytes at the path you hashed

Needed. When someone wants to read the text

A neighbor file. Gets its own digest, or none

Check yourself

1. You have a SHA-256 hex string and the path notes.txt. What is the hex?

2. backup.txt was in the same folder and was not hashed. What digest does it have in this note?

3. The hex was saved without a path. What do you write?