Hashing Explained: What MD5, SHA-1, and SHA-256 Are For

By Daniel Okafor · September 10, 2026 · Security

A hash is a one-way fingerprint, not encryption. Knowing which algorithm is broken, which is fine for integrity checks, and which belongs nowhere near a password.

A cryptographic hash function takes input of any size and produces a fixed-length fingerprint. The same input always produces the same output, a tiny change to the input produces a completely different output, and there is no way to run the process backwards. That one-way property is what makes hashing useful and what makes it fundamentally different from encryption.

What the properties actually guarantee

A good hash function should make it infeasible to find the input from the output, infeasible to find a second input producing the same output, and infeasible to find any two inputs that collide. When people say an algorithm is broken, they mean one of these guarantees has failed in practice, not that the function has stopped working.

The state of the common algorithms

Why passwords need something else

The virtue of SHA-256 is speed, and speed is exactly wrong for password storage. An attacker with a stolen database can compute billions of fast hashes per second on a graphics card and simply try every plausible password. Password storage needs a deliberately slow, memory-hard function such as bcrypt, scrypt or Argon2, tuned so that a single verification takes a noticeable fraction of a second.

A salt, meaning a unique random value stored alongside each hash, is also mandatory. Without it, identical passwords produce identical hashes, which reveals reuse across accounts and allows precomputed rainbow tables to work. Modern password hashing functions handle salting for you, which is another reason to use them rather than assembling your own scheme.

Using hashes correctly

  1. Use SHA-256 to verify downloads, comparing against a checksum published on a different channel from the file.
  2. Compare hashes with a constant-time comparison in security-sensitive code to avoid timing leaks.
  3. Use bcrypt, scrypt or Argon2 for passwords, never a bare SHA function.
  4. Do not hash short, guessable values such as email addresses and treat the result as anonymised; the space is small enough to enumerate.
  5. Record which algorithm produced a stored hash so it can be migrated later.
  6. Use HMAC rather than a naive hash of key and message when authenticating data.

Wrapping up

Hashing verifies, it does not conceal, and the right algorithm depends entirely on whether an adversary is in the picture. SHA-256 for integrity, a slow memory-hard function for passwords, and MD5 for nothing that matters.

Generate MD5, SHA-1 and SHA-256 hashes in your browser.

Try the Hash Generator tool.

SwiftMultiTool — free online tools for everyone. Home · Blog · About · FAQ · Contact