NNonkera
Developer ToolsUpdated July 31, 2026

MD5 vs. SHA-256: Which Hash Should You Use?

The real difference between MD5 and SHA-256, why MD5 is no longer considered secure, and which hash algorithm actually fits your use case.

What both algorithms actually do

MD5 and SHA-256 are both cryptographic hash functions — they take an input of any size and produce a fixed-length output (128 bits for MD5, 256 bits for SHA-256) such that the same input always produces the same output, and even a tiny change to the input produces a completely different result. Where they differ isn't really what they do, but how well they hold up against someone deliberately trying to break that guarantee.

Why MD5 is considered broken

A secure hash function needs to be collision-resistant — it should be computationally infeasible to find two different inputs that produce the same hash. MD5's collision resistance was broken by researchers years ago, and creating an MD5 collision today is fast and practical rather than merely theoretical. That doesn't mean MD5 hashes are meaningless everywhere — for something like a quick, non-adversarial duplicate-file check, a broken collision guarantee simply doesn't matter, since nobody's trying to trick the system. It absolutely does matter anywhere a malicious actor could benefit from engineering a collision, which is why MD5 has been phased out of security contexts industry-wide.

Where SHA-256 stands today

SHA-256, part of the SHA-2 family, has no known practical collision attack and remains the widely recommended default for file integrity verification, digital signatures, and blockchain applications (it's the hash function Bitcoin uses, among others). It's slower to compute than MD5, which is a non-issue for verifying a file's integrity but is precisely why SHA-256 alone still isn't the right choice for password storage — its speed, an advantage for legitimate integrity checks, is a liability against an attacker trying to guess passwords by brute force at high speed.

The practical decision

For anything security-sensitive — verifying a download hasn't been tampered with, checking data integrity, generating a digital fingerprint that needs to resist deliberate forgery — use SHA-256 (or a stronger SHA-2/SHA-3 variant) rather than MD5. For password storage specifically, neither raw MD5 nor raw SHA-256 is the right tool; use a purpose-built, deliberately slow algorithm like bcrypt, scrypt, or Argon2 instead, which are designed to resist brute-force guessing in a way general-purpose hash functions aren't. MD5 remains fine for low-stakes, non-adversarial uses like a quick duplicate-content check where nobody has any incentive to engineer a collision.

Frequently asked questions

Is MD5 completely useless now?

Not for every purpose — it's broken for security uses where someone could benefit from engineering a collision, but it's still fine for low-stakes, non-adversarial tasks like quick duplicate detection.

Should I use SHA-256 for storing passwords?

Not on its own — use a purpose-built, deliberately slow algorithm like bcrypt, scrypt, or Argon2, since SHA-256's speed is actually a liability against brute-force password guessing.

What does a hash 'collision' mean?

Two different inputs producing the identical hash output — a well-designed hash function makes this computationally infeasible to engineer deliberately, which is exactly what's broken in MD5.

Is SHA-256 faster or slower than MD5?

Slower — which doesn't matter for typical integrity-checking use, but is one reason SHA-256 alone still isn't a substitute for a dedicated password-hashing algorithm.

What hash does Git use?

Git has historically used SHA-1 to identify commits and objects, though the broader industry has been moving away from SHA-1 for security-sensitive uses for the same collision-resistance reasons as MD5.