A hash function takes any input and produces a fixed-length output (the hash or digest). The same input always produces the same hash, but even a tiny change in input produces a completely different hash. Hashes are one-way — you can't reverse them to get the original input.
Which algorithm should I use?
SHA-256 — recommended for most use cases
SHA-512 — higher security, larger output
SHA-1 — legacy only, avoid for security
MD5 — checksums only, not for security
Frequently Asked Questions
Can I reverse a hash to get the original text?+
No. Hash functions are designed to be one-way — it's computationally infeasible to reverse them. What attackers do instead is try millions of common inputs and compare hashes (a "dictionary attack"), which is why you should never hash short or common strings for security purposes.
Is MD5 safe to use?+
MD5 is broken for security purposes — collisions (two different inputs producing the same hash) can be generated intentionally. Use MD5 only for non-security purposes like file checksums where you control both inputs. Never use MD5 for passwords or digital signatures.
Why does a space at the end change the hash completely?+
This is called the avalanche effect — a property of good hash functions where a tiny change in input causes a completely different output. Even changing one bit flips roughly half of all output bits. This makes hashes useful for detecting any tampering with data.