Hash functions come up constantly around file integrity and password storage โ here's what they actually do.
What a hash function does
It's a one-way function that takes input data and produces a fixed-length string (a digest). The same input always produces the same output, but the function is designed so that recovering the input from the output is effectively impossible.
Why MD5 and SHA-1 are unsafe
Practical attacks now exist for forcing two different inputs to produce the same hash (a "collision") in MD5 (128-bit) and SHA-1 (160-bit), which has been demonstrated to enable forging digital signatures and certificates. They now only serve casual, non-security file-corruption checks.
SHA-256 and SHA-512 are the current standard
The SHA-2 family (SHA-256, SHA-384, SHA-512) has no known practical collision attack yet, so it's the current standard for file integrity checks, Git commit hashes (currently migrating to SHA-256), and TLS certificate signatures.
Why none of these belong in password storage
Whether MD5 or SHA-256, ordinary hash functions are designed to compute extremely fast, which makes a leaked hash vulnerable to brute-force attacks trying billions of guesses per second on a GPU. Password storage needs a deliberately slow, dedicated function like bcrypt, scrypt, or Argon2.