MD5 Decrypt Online: Why MD5 Cannot Be Decrypted and What "MD5 Decoder" Sites Really Do

"MD5 decrypt" gets typed into search boxes constantly, and the short answer surprises people: an MD5 hash cannot be decrypted, because it was never encrypted. MD5 is a one-way hash function. Yet "MD5 decrypt" websites sometimes do return the original text. They are not decrypting anything; they look it up in huge tables of hashes computed in advance. That difference explains when they work, when they cannot, and what your application should use instead.

Why an MD5 hash cannot be reversed to text

Encryption is reversible by design: with the right key, AES turns ciphertext back into the original. A hash has no key and no way back. MD5 takes an input of any size, one word or a 4 GB file, and always produces 128 bits, written as 32 hexadecimal characters.

MD5("")          = d41d8cd98f00b204e9800998ecf8427e
MD5("password")  = 5f4dcc3b5aa765d61d8327deb882cf99
MD5("123456")    = e10adc3949ba59abbe56e057f20f883e

Because there are infinitely many possible inputs and only 2¹²⁸ outputs, information is lost: countless different texts share every hash. No algorithm can "undo" MD5 and tell you which one was the original. That is why no language, including PHP and MySQL, has an MD5 decrypt function.

What MD5 decoder sites actually do

They keep databases of billions of text-to-hash pairs: leaked password lists, dictionary words in many languages and short combinations of letters and digits. When you paste a hash, they search for it. If someone computed the MD5 of that exact text before, it appears; if not, the site can do nothing.

That is why 5f4dcc3b5aa765d61d8327deb882cf99 "decrypts" instantly to password: it is on every list. The MD5 of a long random passphrase will never appear.

Rainbow tables are a more compact version of the same idea, and cracking tools such as hashcat go further by trying candidates at high speed. MD5 is so fast that a single modern graphics card computes tens of billions of hashes per second, so any password of eight characters or fewer falls quickly.

One practical warning: pasting hashes from your own system into a third-party site hands them over. If they are real users' password hashes, that site can keep them and add whatever it cracks to its database.

Why MD5 is no longer secure

MD5 has two separate problems. The first is speed. A fast hash is exactly what you do not want for passwords, because it speeds up brute-force attacks. A salt, a random value per user, defeats precomputed tables but does not make MD5 any slower.

The second is that MD5 is cryptographically broken. Since 2004, collisions, two different inputs with the same hash, can be generated in seconds on an ordinary computer. In 2008 researchers used this to forge a certificate authority certificate, and the Flame malware (2012) used an MD5 collision to sign code as if it came from Microsoft. MD5 must not be used for signatures, certificates or any integrity check against an attacker.

If you need the original back: use encryption

If your application needs to read the original value again, such as a third-party API token or a document number, MD5 was the wrong tool from the start. You need symmetric encryption with a key kept outside the database.

<?php
// PHP: authenticated encryption with libsodium (bundled since PHP 7.2)
$key = sodium_crypto_secretbox_keygen();          // store it in a secret manager
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
$ciphertext = sodium_crypto_secretbox('secret value', $nonce, $key);
$plain = sodium_crypto_secretbox_open($ciphertext, $nonce, $key);   // 'secret value'

MySQL has AES_ENCRYPT() and AES_DECRYPT(), but encrypting inside the database means sending the key with every query, where it can end up in logs. Encrypting in the application is usually the better design.

If they are passwords: verify, do not decrypt

You never need the original password. At login, you hash what the user typed and compare it with the stored hash. That already works with MD5, but it must be done with a slow, salted algorithm: Argon2id or bcrypt, as OWASP recommends.

<?php
// Sign-up
$hash = password_hash($password, PASSWORD_DEFAULT);   // bcrypt today; PASSWORD_ARGON2ID if available

// Login
if (password_verify($password, $hash)) {
    // correct
}

If you inherit a database of MD5 passwords, you do not need to force everyone to reset. Migrate gradually: on the next successful login, verify against the old MD5 and store a new hash from password_hash(). For accounts that do not log in again, wrap the existing MD5 in bcrypt, password_hash($existingMd5), and verify with password_verify(md5($password), $hash) until the user logs in and you can replace it.

Legitimate uses of MD5 today

MD5 is still fine where there is no attacker: finding duplicate files, detecting accidental corruption of a download, building cache keys or ETags, and sharding data between servers. For anything security-related, use SHA-256 or stronger.

# Compute an MD5 (for integrity, not security)
md5sum file.zip                          # Linux
md5 file.zip                             # macOS
certutil -hashfile file.zip MD5          # Windows cmd
Get-FileHash file.zip -Algorithm MD5     # PowerShell

-- MySQL
SELECT MD5('password');   -- 5f4dcc3b5aa765d61d8327deb882cf99

Sources and further reading

RFC 1321 defines MD5, and RFC 6151 documents its weaknesses and advises against it for security. Xiaoyun Wang and colleagues published the first practical collisions in 2004. The OWASP Password Storage Cheat Sheet recommends Argon2id and bcrypt, and the PHP manual documents password_hash(), password_verify() and libsodium.

Frequently asked questions

Can an MD5 hash be decrypted?

No. MD5 is a one-way hash function, not encryption, so there is no key and no algorithm to reverse it. Sites that "decrypt" MD5 only look the hash up in databases of already known texts.

Why did a website find the text for my MD5 hash?

Because that exact text was already in its database, usually because it is a common or short password. Long random texts do not appear in those tables.

How do I decrypt MD5 in PHP or MySQL?

You cannot; no function exists because MD5 is not reversible. If you need data back, encrypt it with libsodium or AES; if it is a password, verify it with `password_hash()` and `password_verify()`.

Is MD5 safe for passwords?

No. It is far too fast and broken for collisions. Use Argon2id or bcrypt, which are deliberately slow and salted.

How long is an MD5 hash?

32 hexadecimal characters, representing 16 bytes (128 bits), regardless of the input size.

What is MD5 still used for?

Non-adversarial jobs: detecting duplicates, checking files for accidental corruption, cache keys and ETags. For security, use SHA-256 or stronger.