What MD5 is
MD5 is a hash function designed by Ron Rivest in 1992 (RFC 1321). It turns any input into a 128-bit fingerprint, shown as 32 hex characters. It is quick and everywhere, but it is cryptographically broken: two different inputs with the same MD5 can be made on purpose. That makes it fine for spotting accidental changes and unsafe for anything involving an attacker.
What this MD5 generator does
- Text, hex or Base64 input. Text is encoded as UTF-8.
- Hex (lowercase or uppercase) and Base64 output.
- HMAC-MD5 when you enter a key, for old systems that still require it.
- Line break options and a compare box to check a hash you were given.
MD5 examples
| Input | MD5 (hex) |
|---|---|
| (empty text) | d41d8cd98f00b204e9800998ecf8427e |
| abc | 900150983cd24fb0d6963f7d28e17f72 |
| hello | 5d41402abc4b2a76b9719d911017c592 |
Where MD5 is still fine
- Detecting accidental corruption of a download or a copied file, when nobody is trying to fool you.
- Cache keys and ETags, where the hash only names a version of some content.
- De-duplication of files you control.
- Avatar services. Gravatar has long identified a user by the MD5 of the trimmed, lowercase email address, and it now accepts SHA-256 as well.
- Legacy protocols and databases that are defined in terms of MD5.
Where MD5 must not be used
- Passwords. MD5 is very fast, and unsalted MD5 hashes of common passwords can be looked up in seconds. Use bcrypt or Argon2, for example with PHP password_hash(). If you have an old table of MD5 password hashes, re-hash each password with a modern algorithm the next time the user logs in.
- Digital signatures and certificates. A forged MD5 collision certificate was shown in 2008, and the Flame malware used an MD5 collision in 2012.
- Verifying downloads against an attacker. Someone can craft a malicious file with the same MD5. Use SHA-256.
Can an MD5 hash be reversed?
Not mathematically: many inputs share each hash, so the original is not stored in it. But short and common inputs, such as simple passwords, can be found by trying guesses or by using lookup tables. A random 32-character value cannot be found this way.
MD5 compared with SHA-256
| MD5 | SHA-256 | |
|---|---|---|
| Hash length | 128 bits, 32 hex characters | 256 bits, 64 hex characters |
| Collisions can be made | Yes, in seconds | No known attack |
| Use for security | No | Yes |
| Use as a checksum | Yes | Yes |
MD5 in code
// Node.js
require("crypto").createHash("md5").update("hello").digest("hex");
# Python
import hashlib; hashlib.md5(b"hello").hexdigest()
// PHP
echo md5("hello");
# Command line
printf hello | md5sum # Linux
printf hello | md5 # macOS
Get-FileHash -Algorithm MD5 file.zip # PowerShell
Browsers have no built-in MD5 in the Web Crypto API, which is why many sites ask a server to do it. This tool calculates it locally. See also the SHA1 generator, the hash generator, the file hash checker and the hash functions guide.