MD5 Hash Generator
Generate an MD5 hash from text or a file, and compare it against a checksum you already have. MD5 is broken for anything security related. For catching accidental corruption and for cache keys, it still works fine.
Paste a checksum to verify it.
1 MD5 Hash Generator example
Input and result
2
md5("Hello World")
b10a8db164e0754105b7a99be72e3fe5 2 MD5 catches accidents, not attackers
Fine: file integrity
Check that a download arrived intact against a published checksum. Accidental corruption will not produce a matching hash.
Fine: cache keys
Hash a long URL or query into a fixed-length key. A collision here costs a wrong cache hit, which is rare enough to ignore.
Fine: deduplication
Spot identical files in a batch. When a false match would matter, confirm it by comparing the bytes.
Not fine: passwords
Even salted, MD5 is far too fast: a GPU tries billions of guesses a second. Use bcrypt or Argon2, which are slow on purpose.
Not fine: signatures
Chosen-prefix collisions have been practical since 2008, when researchers used one to forge a CA certificate. An attacker can make two different files share an MD5.
Not fine: tamper checks
If someone might have changed the file on purpose, a matching MD5 proves nothing. Use SHA-256 for that check.
3 Why your hash does not match
Check for a trailing newline first. Most editors add one when they save, so hashing a file gives a different result from hashing the text you copied out of it. The other common cause is encoding: the same accented character hashes differently as UTF-8 and as Latin-1, and PHP hashes whichever bytes the string holds.
Uploads are read with FileReader as an ArrayBuffer and hashed as raw bytes, so a file gives you exactly what
md5sum on Linux, md5 on macOS and
Get-FileHash -Algorithm MD5 on Windows report. Typed
text is encoded as UTF-8 first, which is what
md5() in PHP and hashlib.md5(s.encode())
in Python do too.
Quick guide
Computing MD5 checksums for legacy systems
- 01 Type or paste text into the left panel, or click Upload File to hash a file's bytes.
- 02 The hash appears on the right in lowercase and uppercase, with the input size in the header.
- 03 Paste a checksum you already have into the compare box to verify it. A match turns green, a mismatch red.
- 04 Hover a hash and click Copy to put it on the clipboard.
CLI & code
How to generate an MD5 hash in the shell, PHP, Python and Node.js
Command line
bash# A file
md5sum archive.tar.gz # Linux
md5 archive.tar.gz # macOS
Get-FileHash -Algorithm MD5 archive.tar.gz # PowerShell
# A string, without the trailing newline echo adds
printf '%s' 'Hello World' | md5sum
# Verify a published checksum file
md5sum -c CHECKSUMS.md5
# echo adds \n and gives a different hash. This trips people up
# constantly when comparing against a value from an application. PHP
php<?php
echo md5('Hello World'), PHP_EOL;
// b10a8db164e0754105b7a99be72e3fe5
// A file, streamed rather than loaded into memory
echo md5_file('archive.tar.gz'), PHP_EOL;
// Raw binary output, when you need the 16 bytes rather than 32 hex chars
$raw = md5('Hello World', true);
// For anything security related, use one of these instead:
echo hash('sha256', 'Hello World'), PHP_EOL;
echo password_hash('secret', PASSWORD_BCRYPT), PHP_EOL; Python
pythonimport hashlib
print(hashlib.md5(b"Hello World").hexdigest())
# b10a8db164e0754105b7a99be72e3fe5
# Text has to be encoded first, and the encoding changes the result
print(hashlib.md5("Café".encode("utf-8")).hexdigest())
# A large file, in chunks
h = hashlib.md5()
with open("archive.tar.gz", "rb") as f:
for chunk in iter(lambda: f.read(8192), b""):
h.update(chunk)
print(h.hexdigest())
# On a FIPS-enabled system md5() raises unless you pass
# usedforsecurity=False, which is a useful reminder of its status. Node.js
jsconst crypto = require("node:crypto");
const fs = require("node:fs");
console.log(crypto.createHash("md5").update("Hello World").digest("hex"));
// A file, streamed
const hash = crypto.createHash("md5");
fs.createReadStream("archive.tar.gz")
.on("data", (chunk) => hash.update(chunk))
.on("end", () => console.log(hash.digest("hex")));
// Browsers deliberately have no MD5 in the Web Crypto API.
// crypto.subtle.digest supports SHA-1, SHA-256, SHA-384 and SHA-512 only. The Web Crypto API leaves MD5 out on purpose because it is broken, so this page ships its own implementation.
Gotchas
Line-ending differences and case formatting
- The hash does not match the one from the server
- Usually a trailing newline. echo adds one; printf does not. Files saved by an editor usually end in one too.
- Two different files have the same MD5
- That is a collision, and for MD5 it can be produced deliberately in seconds. If the files are meant to be different, this is exactly why MD5 cannot be used to detect tampering.
- The hash differs between PHP and Python for the same text
- Encoding. PHP hashes the bytes of the string as stored; Python needs an explicit .encode(). Make both UTF-8 and they agree.
- ValueError: unsupported hash type md5
- A FIPS-enabled Python or OpenSSL build has MD5 disabled. Pass usedforsecurity=False if the use is non-security, or switch to SHA-256.
- Passwords were stored as MD5 and the database leaked
- Treat every one of them as public. Common passwords are in rainbow tables already. Force a reset and migrate to bcrypt or Argon2, rehashing at login.
Warning
Why MD5 must not be used for passwords or trust
MD5 was designed in 1991 and produces 128 bits. The first collisions were published in 2004; by 2008 researchers had used a chosen-prefix collision to forge a working CA certificate. Today a collision costs seconds on a laptop. None of that affects using it as a checksum against accidental corruption, which is why md5sum is still on every Linux box.
MD5 tells you whether two things are probably the same, but not whether someone changed one of them on purpose. Accidental corruption will not produce a matching hash; a motivated attacker can.
RFCs
RFC 1321 and RFC 6151 MD5 notices
Q&A
MD5 hash questions
Is MD5 still safe to use?
Not for anything security related. Collisions have been practical since 2004 and a laptop produces one in seconds, so do not use MD5 for signatures, certificates or password storage. It still works as a non-security checksum: cache keys, deduplication, or a quick check that a file transferred intact.
What should I use instead?
SHA-256 for integrity and signatures, bcrypt or Argon2 for passwords. Both have tools on this site.
Can I reverse an MD5 hash?
No, a hash cannot be computed backwards. However, rainbow tables look the hash up in a precomputed list, which is why an unsalted MD5 of a common password is effectively plaintext.
Can I hash a file?
Yes. Upload File reads it as raw bytes, so the result matches md5sum on Linux or Get-FileHash -Algorithm MD5 on Windows.
Why does my hash differ from the server's?
Nearly always a trailing newline or a different text encoding. A file ending in \n hashes differently from the same text without it, and UTF-8 differs from UTF-16 for anything outside ASCII.