Encryption hides data and can be undone with a key. Hashing does something different: it makes a short code from data, called a hash or fingerprint, which cannot be undone at all. Fingerprints are how computers check that nothing has changed.
What a hash is
Each of the 64 characters is a hexadecimal digit: one of 0–9 or a–f, 16 possibilities, which is 4 bits. So 64 characters × 4 bits = 256 bits.
SHA-256
A hash function turns any input into a short, fixed-length string called a hash, digest or fingerprint. This is SHA-256, the most widely used one. Its fingerprint is always 64 characters long, written with the digits 0–9 and letters a–f.
Four properties
- Same input, same fingerprint, every time, on every computer.
- Small change, completely different fingerprint. Changing one character changes most of the 64 characters (about half of the 256 bits).
- One way. You cannot work back from a fingerprint to the input.
- No two inputs found with the same fingerprint. Such a pair is called a collision. Collisions must exist, because there are more possible inputs than fingerprints, but for a good hash nobody can find one.
Hashes that are broken
Older hash functions have lost the fourth property. Researchers found collisions in MD5 in 2004, and in 2017 a team from Google and CWI Amsterdam published two different PDF files with the same SHA-1 fingerprint. Both are now retired for security uses. Use SHA-256 or the newer SHA-3.
HASH-1 counts as completed once you step through the figure to its last step.