What Is a Cryptographic Hash Function?
A cryptographic hash function takes any input - a word, a sentence, or an entire file - and turns it into a fixed-length string of characters called a hash (or digest). It has three defining properties: it's deterministic (the same input always produces the exact same output), it's fixed-length (a one-character input and a ten-gigabyte file produce hashes of the same length), and it's one-way - there's no practical way to reverse a hash back into the original input.
A good hash function is also highly sensitive to input: changing even a single character produces a completely different, unpredictable hash, with no visible relationship to the original. This property, called the avalanche effect, is what makes hashing useful for detecting even the smallest change to a piece of data.
MD5 vs SHA-1 vs SHA-2 - Which Should You Use?
| Algorithm | Output Length | Cryptographically Secure? |
|---|---|---|
| MD5 | 128 bits (32 hex chars) | No - broken, collisions are practical |
| SHA-1 | 160 bits (40 hex chars) | No - broken, collisions demonstrated |
| SHA-256 | 256 bits (64 hex chars) | Yes |
| SHA-384 | 384 bits (96 hex chars) | Yes |
| SHA-512 | 512 bits (128 hex chars) | Yes |
"Broken" means a deliberate attacker can craft two different inputs that produce the same hash (a collision) faster than brute force - it does not mean MD5 or SHA-1 are useless. Both remain perfectly fine for basic integrity checks, like confirming a download wasn't accidentally corrupted, since nobody is trying to trick that check on purpose. For anything security-critical, stick to the SHA-2 family (SHA-256 and up).
Common Use Cases for Hashing
Frequently Asked Questions
Non-cryptographic hash functions, like the ones used internally by hash tables or a language's built-in hashCode(), are optimized purely for speed and even distribution - they're not designed to resist attack. A cryptographic hash function like MD5, SHA-1, or the SHA-2 family adds two extra guarantees: it must be extremely hard to find two inputs that produce the same output (collision resistance), and extremely hard to reverse a hash back to its input (preimage resistance). Those guarantees are what make cryptographic hashes suitable for integrity checks and security use cases.
No. Raw hashing alone - even with a strong algorithm like SHA-256 - is not safe for password storage, because identical passwords produce identical hashes and attackers can precompute lookup tables. Real systems add a unique random salt per password and use a slow, dedicated password-hashing algorithm like bcrypt, scrypt, or Argon2 instead of a general-purpose hash function.
A hash function is designed to be one-way: computing the hash from an input is fast, but there's no mathematical shortcut to go from the hash back to the input - the only option is to guess inputs and hash them until one matches, which becomes computationally infeasible as the input space grows. This is also why hashing isn't encryption - encryption is reversible with the right key, hashing never is, by design.
SHA-256 and the other algorithms in this tool are general-purpose hash functions, deliberately built for speed so they can hash gigabytes of data quickly for checksums and integrity checks. Password hashing needs the opposite property: algorithms like bcrypt, scrypt, and Argon2 are deliberately slow and memory-hungry, so an attacker trying millions of password guesses per second against a stolen database gets slowed to a crawl. That's why this tool's fast SHA/MD5 output should never be used directly to store a password.
In theory yes - this is called a collision, and it's mathematically unavoidable since a fixed-length hash has far fewer possible outputs than the number of possible inputs. For SHA-256 and SHA-512, no practical collision has ever been found. For MD5 and SHA-1, deliberate collisions have been demonstrated, which is why they're no longer trusted for security purposes.