You copy a file, hash both sides, and the strings don't match. Most of the time the file is fine — the string is not.
Four places where identical content turns into different hash text. All four were checked in a shell and in Python 3 before writing this.
1. Line endings are bytes, and editors hide them
printf 'a\n' > lf.txt # 60b725f10c9c85c70d97880dfe8191b3 printf 'a\r\n' > crlf.txt # 933222b19ff3e7ea5f65517ea1f7d57e Both files show a single line a in any editor. The digests share nothing. core.autocrlf, a Windows editor's save, and sed -i on a mounted volume all rewrite these bytes without changing what you see. If a checksum fails only on the machine that edits the file, suspect the line ending before you suspect the transfer.
2. The shell adds a byte you did not type
printf abc | md5 # 900150983cd24fb0d6963f7d28e17f72 echo abc | md5 # 0bee89b07a248e27c83fc3d5951213c1 echo appends a newline, printf does not. Same three characters, two unrelated digests, and hashlib.md5(b'abc').hexdigest() matches only the first. The same effect shows up in code: reading a file as text instead of bytes normalizes CRLF to LF, so two code paths hashing "the same file" hash different byte strings. On a file containing line1 + CRLF + line2, a binary read gives 4ad3ef64dfb83f7a… and a text-mode read gives 2751a3a2f303ad21….
3. One digest, three strings
The digest is fixed. How you print it is not.
hex 900150983cd24fb0d6963f7d28e17f72 base64 kAFQmDzST7DWlj99KOF/cg== upper 900150983CD24FB0D6963F7D28E17F72 All three are the same 128 bits. Tool output adds decoration as well: md5sum prints hash filename, openssl dgst prints (stdin)= hash. Store one of those lines raw in a database column and every later comparison fails for a reason nobody thinks to check.
4. Storing the digest as a number eats leading zeros
sha256("39") starts with 0b918943df09…. Parse it as an integer, store it, format it back, and you get b918943df096… — 63 characters instead of 64, no error anywhere. A hex digest is a fixed-width string, not a number. Check the length before you compare, and distrust any column that lets the width change.
The order that saves time
Check length, then case, then encoding, then bytes. Normalize both sides to lowercase hex, hash files in binary mode, and never compare a digest against a line that still has a filename attached.
When I need to tell which of these I'm hitting, I paste the exact bytes into this hash generator. It runs SHA-1, SHA-256, SHA-384 and SHA-512 through the browser's Web Crypto API, hashes a dropped file as well as typed text, and computes on your machine — which makes a text-vs-file difference show up immediately instead of after a round trip.