What a hash function does
A cryptographic hash function takes input of any size and produces a fixed-length string of characters. Feed it a single word and you get 64 hexadecimal characters from SHA-256. Feed it an entire book and you still get 64 characters. Crucially, the same input always produces the same output, and changing even one character of the input produces a completely different result.
Hashing is one-way by design. There is no operation that turns a hash back into the original text, which is what makes it useful for verification: you can prove two things are identical without holding either of them.
Verifying file integrity
The most common everyday use is checking that a download arrived intact. Software projects publish the SHA-256 hash of their release files. After downloading, you compute the hash yourself and compare. If the values match, the file is byte-for-byte identical to what was published. If they differ, something went wrong — a corrupted download, or in rarer cases a tampered file.
Which algorithm to use
SHA-256 is the sensible default for almost everything. It is fast, widely supported, and has no known practical weaknesses. SHA-512 produces a longer digest and is marginally faster on 64-bit hardware, making it a reasonable choice where you want extra margin.
SHA-1 should be treated as broken for security purposes. Practical collision attacks against it were demonstrated in 2017, meaning it is possible to construct two different inputs that produce the same hash. It survives in legacy systems and in Git's internals, so you will still encounter it, but it should not be chosen for anything new.
MD5 has been thoroughly broken for far longer and should never be used where security matters. It remains in occasional use as a fast non-security checksum for detecting accidental corruption.
Hashing and passwords
This deserves emphasis because it is a widespread and damaging mistake. General-purpose hash functions like SHA-256 are the wrong tool for storing passwords, precisely because they are fast. Speed helps an attacker: modern hardware can compute billions of SHA-256 hashes per second, so a leaked database of SHA-256 password hashes falls quickly to brute force.
Password storage requires a deliberately slow algorithm designed for the purpose — bcrypt, scrypt, or Argon2 — combined with a unique random salt per password. These are engineered so that computing each hash costs meaningful time and memory, making mass cracking impractical.
Computed in your browser
Hashing here uses the Web Crypto API built into your browser. Nothing you type is transmitted or stored, so you can safely hash sensitive strings for comparison without them leaving your machine.
Frequently Asked Questions
Can I reverse a hash back to the original text?
No. Hash functions are one-way. So-called reverse lookup sites work only by having previously hashed a huge dictionary of common inputs and storing the pairs.
Which algorithm should I choose?
SHA-256 for almost all purposes. Use SHA-512 if you want a longer digest. Avoid SHA-1 and MD5 for anything security related, as both have practical collision attacks.
Why is MD5 still available in some tools?
It remains in use as a fast checksum for detecting accidental file corruption, where deliberate tampering is not a concern. It is unsuitable wherever security matters.
Can I use SHA-256 to store passwords?
No. It is far too fast, which helps attackers. Use bcrypt, scrypt or Argon2 with a unique salt per password.
Is my text sent to a server?
No. Hashing uses your browser's built-in Web Crypto API and happens entirely on your device.