What a hash is
A hash function is a published recipe that takes any amount of data, from one word to a whole movie file, and produces a short, fixed-length value called a hash or digest. Think of it as a fingerprint of the data.
- Any inputA word, a password, a document or a whole download.
- Hash functionA public algorithm such as MD5 or SHA-256. No secret key is involved.
- Fixed-length digestAlways the same length for a given algorithm, written as hexadecimal characters.
- CompareSame input, same digest. Different input, a completely different one.
Hashing only goes one way. You can hash the input again to compare, but you cannot rebuild the input from the digest.
A good hash function has three properties. It is deterministic, so the same input always gives the same output. It is one-way, so finding an input that produces a given digest is not practical. And it is collision resistant, so finding two different inputs with the same digest is not practical either.
A worked example
The word hello hashes to these values (in hexadecimal):
MD5 (32 characters): 5d41402abc4b2a76b9719d911017c592
SHA-1 (40 characters): aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
SHA-256 (64 characters): 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
Anyone, on any computer, gets exactly these values. You can confirm them with our hash generator.
See the avalanche effect
Good hashes show an avalanche effect: a tiny change in the input flips about half the bits in the output. That is why comparing two digests is enough to tell whether a file has been altered, even by one byte.
Try it: change one character
Type any two messages that differ by a single character. The characters of the second hash that differ from the first are highlighted.
- Hash of A
- 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
- Hash of B
- 1589999b0ca6ef8814283026a9f166d51c70a910671c3d44049755f07f2eb910
118 of 256 bits are different. About half is what a good hash gives for any change, however small.
Hashing runs in your browser. Nothing you type is sent anywhere.
MD5 vs SHA-1 vs SHA-256
The algorithms differ in output size and in how well they have stood up to attack. Longer digests are one factor; cryptanalysis is the other, and it is why the older two have been retired for security work.
Length alone does not make an algorithm safe. MD5 and SHA-1 are broken by weaknesses in their design, not by their length.
Show the data as a table
| Method | Bits |
|---|---|
| MD5 | 128.0 |
| SHA-1 | 160.0 |
| SHA-256 | 256.0 |
| SHA-512 | 512.0 |
| Algorithm | Digest size | Status for security use | Fine for |
|---|---|---|---|
| MD5 | 128 bits (32 hex characters) | Broken: practical collisions (RFC 6151) | Spotting accidental corruption, cache keys |
| SHA-1 | 160 bits (40 hex characters) | Broken for collisions (SHAttered, 2017); NIST is retiring it by 2030 | Legacy systems only, such as older Git repositories |
| SHA-256 | 256 bits (64 hex characters) | Current and recommended (FIPS 180-4) | File integrity, signatures, general purpose |
| SHA-512 | 512 bits (128 hex characters) | Current and recommended (FIPS 180-4) | The same, with a longer digest |
The 2017 SHAttered attack, by researchers at CWI Amsterdam and Google, produced two different PDF files with the same SHA-1 hash. It proved in practice what cryptographers had warned for years, and it sped up the move away from SHA-1.
What hashing is used for
Checking downloads
Publishers list the SHA-256 of an installer or disk image. You hash the file you downloaded and compare. If even one byte differs, the digests differ. Our file hash checker does this in your browser without uploading the file.
Storing passwords
Sites should store a hash of each password, not the password. But the hash must be slow and salted (a random value added per user). OWASP recommends Argon2id, with scrypt or bcrypt as alternatives. A plain SHA-256 is too fast, as the worked example below shows.
Digital signatures
Signing a large document means signing its hash. Certificates, software updates and many secure messaging systems rely on SHA-256 or SHA-512 for this, so a collision in the hash would let an attacker swap documents.
Everyday software
Hashes also act as quick identifiers: finding duplicate files, naming cached items, and checking that data copied between systems is intact. For those jobs a fast hash is useful, and security strength matters less.
Why a fast hash is a bad password store
Suppose a site stored an 8-character random password with the full keyboard (94 symbols), and its database leaked. A fast hash lets an attacker test about 100 billion guesses a second on specialised hardware, so the average time to find the password is about 8 hours. A slow password hash (about 100,000 guesses a second on the same assumptions) stretches that to about 966 years. Same password, a very different outcome. The speeds are illustrative, but the gap is why password storage is a different job from file checking. Our password guide has a calculator for this.
Hashing myths
Myth Hashing is the same as encryption.
Fact Encryption is reversible with a key. A hash has no key and no reverse: it is designed to be one-way.
Myth A hash cannot be cracked, so any hash is safe for passwords.
Fact Attackers do not reverse the hash; they guess inputs and hash each guess. A fast hash lets them guess billions of times a second, so passwords need a slow, salted hash.
Myth MD5 is useless.
Fact It is broken against deliberate attack, but it still detects accidental changes. Do not use it where someone might tamper with the data on purpose.
Myth Longer hashes are always safer.
Fact SHA-1 is longer than MD5 and is also broken. Safety depends on the design as well as the length.
Verify a download: checklist
Check a file’s hash
Test yourself
Five-question quiz
Pick an answer to see feedback straight away.
Show the answer
Hashing is one-way and uses no key. Encryption is designed to be reversed with the right key. A hash is designed so that it cannot be reversed.
Show the answer
SHA-256. SHA-256 is part of the SHA-2 family in FIPS 180-4. MD5 and SHA-1 have practical collision attacks.
Show the answer
About half. This is the avalanche effect. Each output bit has roughly a 50% chance of flipping, so about 128 of 256 bits change.
Show the answer
A slow, salted hash such as Argon2id or bcrypt. OWASP recommends Argon2id, with scrypt and bcrypt as alternatives. They are deliberately slow and salted to resist mass guessing.
Show the answer
Delete it and download again from the official source. A mismatch means the file differs from the original, through corruption or tampering. Compare the whole digest and download again.
Tools used in this guide
Frequently asked questions
What is hashing in simple terms?
Hashing converts any data into a short fixed-length fingerprint using a published formula. The same data always gives the same fingerprint, and a small change gives a completely different one. You cannot rebuild the data from the fingerprint.
Is MD5 still safe to use?
Not for security. Researchers can create two different inputs with the same MD5 hash, as RFC 6151 notes. It is still fine for non-security jobs such as detecting accidental corruption or generating cache keys.
Can a SHA-256 hash be reversed?
Not directly. Short or common inputs can be found by guessing them and hashing each guess, which is why a leaked hash of a weak password is still a risk. Long random inputs cannot be found this way.
What is the difference between hashing and encryption?
Encryption transforms data so that the right key can restore it. Hashing has no key and no way back; it exists to compare and verify data, not to hide it for later reading.
Why not store passwords with SHA-256?
SHA-256 is designed to be fast, which helps attackers who steal a database test billions of guesses a second. Password hashes such as Argon2id, scrypt and bcrypt are deliberately slow and use a salt per user.
Sources and further reading
- RFC 1321: The MD5 Message-Digest Algorithm (opens in a new tab) – the MD5 specification
- RFC 6151: Updated Security Considerations for MD5 (opens in a new tab) – why MD5 is unsuitable where collisions matter
- NIST FIPS 180-4: Secure Hash Standard (opens in a new tab) – SHA-1 and SHA-2 specifications
- NIST: Retires SHA-1 cryptographic algorithm (opens in a new tab) – the 2030 phase-out date
- SHAttered: the first SHA-1 collision (opens in a new tab) – the 2017 collision from CWI Amsterdam and Google
- OWASP Password Storage Cheat Sheet (opens in a new tab) – Argon2id, scrypt and bcrypt guidance
This guide gives general information. Crack-time figures come from a simple model with assumed guessing speeds, not measurements.