What is a Hash Function?
A cryptographic hash function converts arbitrary data into a fixed-size string of characters (the "hash" or "digest"). Even a tiny change in the input produces a completely different hash — this is called the avalanche effect. Hash functions are one-way: you cannot reverse a hash to get the original data.
Common uses include verifying file integrity (checksums), storing passwords securely, digital signatures, and data deduplication.
FAQ
Is MD5 safe for passwords?
No. MD5 is fast, which makes it easy to brute-force. Never use MD5 or SHA-1 for password storage. Use bcrypt, scrypt, or Argon2 instead. MD5 is still useful for non-security checksums like verifying file downloads.
Which algorithm should I use?
For security-sensitive applications, use SHA-256 or SHA-512. For quick integrity checks where security isn't a concern (e.g., comparing file copies), MD5 is fine. SHA-1 is being phased out for security uses but still appears in legacy systems.