Hash Generator
Generate cryptographic hashes (SHA-1, SHA-256, SHA-512) from any text. Uses the Web Crypto API.
What is a hash?
A cryptographic hash function turns any input - a word, a document, a disk image - into a fixed-length string of characters. The same input always produces the same hash, but the process only runs one way: you cannot recover the input from the hash.
That one-way property is what makes hashes useful. They act as a compact fingerprint for data, letting you verify that something has not changed without needing the original to compare against.
Key takeaways
- Hashing is one-way and is not encryption - there is no key and no way back.
- The same input always gives the same hash; one changed bit changes everything.
- MD5 and SHA-1 are broken and must not be used for security.
- SHA-256 is the sensible default for integrity checking.
- None of these are suitable for storing passwords - use Argon2, scrypt or bcrypt.
The algorithms compared
| Algorithm | Output length | Status | Use it for |
|---|---|---|---|
| MD5 | 128 bits (32 hex) | Broken since 2004 | Non-security checksums only |
| SHA-1 | 160 bits (40 hex) | Broken since 2017 | Legacy compatibility only |
| SHA-256 | 256 bits (64 hex) | Secure | The general-purpose default |
| SHA-512 | 512 bits (128 hex) | Secure | Where a longer digest is wanted |
SHA-512 is often faster than SHA-256 on 64-bit hardware despite producing a longer output, because it operates on 64-bit words natively.
The avalanche effect
A good hash function changes completely when the input changes even slightly. Hashing "hello" and "hellp" - one letter different - produces two entirely unrelated SHA-256 outputs with roughly half the bits differing.
This is exactly what makes hashes useful for integrity checking. You cannot tell from two hashes whether the inputs were similar, and any change to a file - a single flipped bit - produces an obviously different fingerprint.
What hashes are legitimately used for
- File integrity verification. Compare a downloaded file's hash against the publisher's to confirm it arrived intact and unaltered.
- Detecting duplicate files by fingerprint rather than by comparing contents byte by byte.
- Digital signatures, where a document's hash is signed rather than the whole document.
- Blockchain and version control. Git identifies every commit by a hash of its contents.
- Deduplication in storage and backup systems.
- Cache keys and content-addressed storage.
Why you must not hash passwords with these
| Function | Designed for | Guesses per second on a GPU |
|---|---|---|
| SHA-256 | Speed | Around 10 billion |
| bcrypt (cost 12) | Slowness | Around 20 thousand |
| scrypt | Slowness + memory cost | Similar to bcrypt |
| Argon2id | Slowness + memory + parallelism cost | Around 2 thousand |
The difference is roughly a million-fold. That is the gap between a password database being cracked overnight and being effectively uncrackable.
Rainbow tables and salting
A rainbow table is a precomputed lookup of hashes for common inputs. Because the same input always produces the same hash, an unsalted hash of a common password can simply be looked up rather than cracked.
A salt is a unique random value added to each input before hashing. It means identical passwords produce different hashes, which makes precomputed tables useless - each password must be attacked individually. Modern password hashing functions handle salting automatically.
Verifying a downloaded file
- Find the publisher's official checksum, ideally on a different domain or channel from the download itself.
- Compute the hash of your downloaded file using your operating system's built-in tool.
- Compare the two strings carefully - check the whole string, not just the first few characters.
- If they differ, do not run the file. It is either corrupted or has been tampered with.
| Platform | Command |
|---|---|
| Windows (PowerShell) | Get-FileHash file.zip -Algorithm SHA256 |
| macOS | shasum -a 256 file.zip |
| Linux | sha256sum file.zip |
Frequently Asked Questions
What is a hash function?
A function that converts any input into a fixed-length string of characters. The same input always produces the same output, but the process is one-way - you cannot recover the input from the hash. It acts as a compact fingerprint for data.
Can a hash be reversed or decrypted?
No. Hashing is not encryption and has no key. What attackers actually do is guess inputs, hash them, and compare - which works well for short or common inputs but not for long random ones. There is no mathematical way back.
Which hash algorithm should I use?
SHA-256 for general-purpose integrity checking. SHA-512 if you want a longer digest, and it is often faster on 64-bit hardware. Avoid MD5 and SHA-1 for anything security-related, though they remain fine for detecting accidental file corruption.
Why are MD5 and SHA-1 considered broken?
Because researchers can construct two different inputs that produce the same hash, at practical cost - MD5 since 2004 and SHA-1 since 2017. That defeats any use where the hash is meant to prove a document is the one you expect.
Can I use SHA-256 to store passwords?
No. SHA-256 is designed to be fast, and a modern GPU computes billions of them per second, so a stolen database falls quickly to a dictionary attack. Use Argon2id, scrypt or bcrypt, which are deliberately slow and memory-hard.
What is a salt?
A unique random value added to each input before hashing, so that identical passwords produce different hashes. It defeats rainbow tables - precomputed hash lookups - by forcing each password to be attacked individually. Modern password hashing functions salt automatically.
Why does changing one character change the whole hash?
This is the avalanche effect, and it is a deliberate design property. A single-bit change to the input flips roughly half the output bits. It means you cannot infer anything about input similarity from hash similarity, and any file change is immediately obvious.
How do I verify a downloaded file with a hash?
Compute the file's hash with your operating system's tool - Get-FileHash on Windows, shasum on macOS, sha256sum on Linux - and compare it with the publisher's published value. Compare the entire string, and do not run the file if they differ.
Is my input sent to a server when I hash it here?
No. Hashing runs entirely in your browser using the Web Crypto API. Nothing is transmitted, logged or stored.