Developer Guide

MD5 vs SHA-256, and Why Neither Should Hash Your Passwords

By Muhammad Waseem Updated 938 words

A cryptographic hash takes any input and returns a fixed-size fingerprint that is one-way, you cannot reverse it, unlike encryption, deterministic, same input, same output, and avalanche-sensitive, one flipped bit changes everything. The two you meet constantly are MD5, a 128-bit, 32-character hex digest, and SHA-256, a 256-bit, 64-character hex digest. They are not simply "weaker" and "stronger" versions of the same tool, one is cryptographically broken, and the other is fine.

The most important, and most misunderstood, point. Both are the wrong choice for storing passwords. Speed that makes SHA-256 great for integrity makes it terrible for secrets, because a good hashing algorithm for data is a great guessing engine for GPUs. This guide explains what each hash is actually for, and why password storage needs a completely different class of function.

What a hash is, and what it is not

Hashing is not encryption. Encryption is reversible with a key. A hash has no key and no inverse. You hash a file to detect corruption or a change. You do not "decrypt" an MD5 back to the original. Any tool that claims to "decrypt" a hash is really just looking up the input in a precomputed table.

These generators compute a hash of text you type, entirely in your browser, and they do exactly that, nothing more. They have no salt, no iterations and no secret, which is precisely why they are fine for fingerprints and dangerous for passwords.

MD5, broken for security, still common for non-adversarial uses

MD5 produces a 32-character hex digest and its collision resistance is thoroughly broken, anyone can craft two different inputs with the same MD5 cheaply. That rules it out anywhere an attacker might exploit collisions. Code-signing, certificate trust, integrity of files that a hostile party could tamper with, or "proof" two things differ.

It is still seen as a quick, non-security checksum, detecting accidental corruption, cache keys, dedup within trusted data, and in legacy systems. But when in doubt, reach for SHA-256 instead. The extra 32 characters are almost never a reason to use a broken primitive.

SHA-256, a sound choice for integrity and identity

SHA-256, part of the SHA-2 family, has no practical collisions known and is the default for tamper-evidence and content addressing. It is what Git uses to name objects, what TLS certificates and software signatures rely on, and what blockchain-style digests use. If you need to prove a file has not changed, or to derive a stable ID from content, SHA-256 is the right tool.

It is fast by design, which is exactly what you want for hashing large volumes of public data, and exactly what you do not want for protecting a small secret, as the next section explains.

Why you must never store passwords with MD5 or SHA-256

Password verification is the opposite problem. You want hashing to be slow and expensive so brute force is costly, and you want it unique per user so one stolen table cannot be attacked in bulk. Fast general hashes give you neither, a GPU tries billions of SHA-256, let alone MD5, attempts per second, and unsalted digests fall to rainbow tables. A single fast hash of a common password is effectively plaintext to a serious attacker.

The correct tools are deliberately slow, salted, work-factor key-derivation functions. Argon2id, memory-hard, current best practice, or bcrypt, with scrypt or PBKDF2 as alternatives. The salt makes each hash unique and defeats precomputed tables. The tunable cost makes guessing expensive. Our generators provide neither salt nor iterations, so they are the wrong class of tool for passwords by design.

JobRight primitiveWrong or unsafe choice
File integrity or tamper evidenceSHA-256MD5, collisions are practical.
Content address or dedup IDSHA-256Anything an attacker can collide.
Password storageArgon2id or bcrypt, salted, slowMD5, SHA-1, SHA-256, SHA-512.
Reversible encoding of bytesbase64, encoding, not a hashCalling base64 "encryption."
Accidental-corruption checksumSHA-256, MD5 legacy onlyTrusting MD5 against a foe.

A frequent confusion to kill outright. Base64 is not hashing or encryption at all, it is a reversible encoding of arbitrary bytes into safe text. Anything base64-encoded can be decoded instantly. It provides zero confidentiality or integrity.

Frequently Asked Questions

Is SHA-256 good enough to hash passwords?

No. SHA-256 is intentionally fast, and fast hashing is the worst property for passwords because GPUs can try billions of guesses per second. Store passwords with a slow, salted KDF such as Argon2id or bcrypt, not a raw hash, and never with MD5 or unsalted SHA.

Why is MD5 considered broken?

Because collisions are practical to produce. Two different inputs that yield the same MD5 digest can be crafted cheaply. Anywhere an adversary could exploit that, signatures, certificates, tamper evidence, MD5 is unsafe. Use SHA-256 instead.

Can you decrypt an MD5 or SHA-256 hash?

No. Hashing is one-way with no key and no inverse. What tools sometimes call "decryption" is just looking up a known input in a precomputed table. A hash of a random or high-entropy value cannot be reversed at all.

Is base64 a form of encryption?

No. Base64 is a reversible encoding of bytes into text safe to paste around. It has no key and no secrecy. Anything base64-encoded is trivially decoded. Use a real cipher for confidentiality and a hash for integrity, base64 is neither.

MD5 vs SHA-256 for checking a download?

For detecting an accidental corrupted download either works, but if any party could deliberately tamper with the file, use SHA-256, because MD5 collisions are practical. The safe default is SHA-256 unless a legacy system requires MD5.

What does the salt actually do?

A unique random salt per password makes every hash different, so attackers cannot use rainbow tables or hash one guess against many users, and the same password hashes differently for two accounts. Combined with a slow work factor, it turns bulk guessing into an expensive, per-target task.

Related guides

Browse all 57 guides

Recognised & listed on