How to get a hash
- Choose Text and type or paste what you want to hash, or choose File and pick a file from your device. All fourteen hashes appear straight away. To hash raw bytes, set The box holds to hex or Base64.
- Press Copy beside the one you need. Under Show hashes as, choose capitals if the other side writes hashes in capitals, or Base64 for formats such as Subresource Integrity.
- To check a download, hash the file, then paste the checksum from the download page into Check against a hash you were given. The matching row is marked.
- To make an HMAC, type a secret key. Every hash then includes the key.
What a hash is
A hash function reads any amount of data, from one letter to a movie file, and produces a short fixed-length fingerprint. Three properties make it useful. The same data always gives the same hash. A change of even one character gives a completely different hash. And it is not practical to work backwards from a hash to the data. The result is usually written as hexadecimal digits: 32 for MD5, 40 for SHA-1, 64 for SHA-256, 96 for SHA-384 and 128 for SHA-512. It can also be written in Base64, which is shorter.
MD5, SHA-1 and the SHA-2 family
- MD5 (128 bits) is old and fast. Different files with the same MD5 hash can be made on purpose, so it is not safe for security, but it still serves as a quick check for accidental damage.
- SHA-1 (160 bits) was the standard for years and has also been broken for security use. Git still shows SHA-1 names for its objects, and many older download pages publish SHA-1 checksums.
- SHA-256, SHA-384 and SHA-512 belong to the SHA-2 family and are the ones to choose today. SHA-256 is used in certificates, software signing and block chains and is the usual default.
A longer hash is not always better for your purpose. SHA-256 is already far beyond what can be attacked by brute force, and SHA-512 can even be faster on 64-bit computers, so the choice is mostly about matching what the other side uses.
The other hash types
- CRC32 is a checksum, not a cryptographic hash. ZIP, PNG and gzip files store a CRC32 to catch accidental damage, and it is quick to compute, but anyone can change data and keep the same CRC32, so never rely on it against tampering.
- SHA-224 and SHA-512/256 are shortened members of the SHA-2 family, defined in the same standard (FIPS 180-4). Each starts from its own initial values, so it is not just the first part of SHA-256 or SHA-512.
- SHA3-256 and SHA3-512 are the SHA-3 standard (FIPS 202), built on the Keccak design, which works quite differently from SHA-2. That makes SHA-3 a safe second choice if a weakness were ever found in SHA-2.
- Keccak-256 is the version of Keccak from before SHA-3 was finalized, with different padding. Ethereum uses it, so it gives different results from SHA3-256 for the same input.
- BLAKE2b and BLAKE3 are modern hashes designed to be very fast in software while staying secure. BLAKE2b (512-bit here) is specified in RFC 7693 and is built into Python and many tools. BLAKE3 is newer and faster still, and its command-line tool is
b3sum. - RIPEMD-160 is a 160-bit hash from the 1990s. It is best known for Bitcoin addresses, which use RIPEMD-160 of a SHA-256 hash.
The SHA-1 and SHA-2 hashes come from your browser’s own Web Crypto. The other types are computed with noble-hashes, an audited JavaScript library (MIT license).
Where hashes are used
Hashes are everywhere in computing, usually out of sight. Backup and sync programs use them to find duplicate files without comparing every byte. Web servers use them to build the ETag that tells a browser whether a cached copy is still current. Git names every commit and file by its hash, so any change to history changes the names. Digital signatures sign the hash of a document instead of the whole document, which is much faster. Package managers record the expected hash of each library so that a tampered download is rejected. And block chains link each block to the hash of the one before it. In all of these, the same property does the work: if even one bit of the data changes, the hash changes, so comparing two short hashes is a reliable way to compare two very large things.
Check that a download is intact
Software sites often publish a checksum next to the download link. After the download finishes, hash the file with the same algorithm and compare the result. If every character matches, the file you have is exactly the file that was published, with nothing lost on the way. If it differs, download it again; if it differs a second time, do not run it. Keep in mind one limit: a checksum that sits on the same page as the file protects against a broken download, but not against a page that has itself been tampered with. For that, use a checksum or a signature obtained from a separate trusted source.
HMAC: a hash with a secret key
An HMAC combines a hash with a secret key. Anyone can compute a plain SHA-256 of a message, but only someone who holds the key can compute the HMAC-SHA-256 of it. Payment providers, code hosting sites and chat services use this to sign the webhooks they send: the receiver computes the HMAC of the body with the shared key and compares it with the signature in the header. If they match, the message came from the sender and was not changed. The key box above makes every result an HMAC, so you can reproduce a signature while debugging an integration.
Why a hash alone is not a password store
It can look natural to store the SHA-256 of each password, but it is a poor idea. These functions are designed to be fast, so a thief with a stolen list can test billions of guesses a second, and common passwords have well known hashes that can simply be looked up. Use a function designed for the job: Argon2, bcrypt or scrypt, each of which is slow on purpose and adds a random salt for every password. Every serious web framework includes one.
Get a hash in code and on the command line
- JavaScript:
crypto.subtle.digest('SHA-256', bytes)in browsers and Node.js, which returns the hash as bytes. - Python:
hashlib.sha256(b'text').hexdigest()afterimport hashlib. - PHP:
hash('sha256', $text), ormd5($text)for MD5. - Java:
MessageDigest.getInstance("SHA-256"). - MySQL:
SELECT SHA2('text', 256);orSELECT MD5('text'); - PostgreSQL:
SELECT encode(sha256('text'), 'hex');orSELECT md5('text'); - Python, other types:
hashlib.sha3_256(data),hashlib.blake2b(data)andzlib.crc32(data). - Linux:
sha256sum fileormd5sum file;openssl dgst -sha3-256 filefor SHA-3;b3sum filefor BLAKE3. - macOS:
shasum -a 256 fileormd5 file. - Windows PowerShell:
Get-FileHash file -Algorithm SHA256, or in the command promptcertutil -hashfile file SHA256.
Tips
- Watch the line break. Text typed in a file usually ends with a new line, and that one invisible character changes the whole hash. This page hashes exactly what is in the box.
- Use the same algorithm as the published checksum. A 64-character checksum is usually SHA-256; the comparison box checks every row and tells you which algorithms a pasted hash could be.
- Text uses UTF-8. Letters outside plain English are hashed as UTF-8 bytes, which is what most systems expect.
Related tools: encode data for transport with the Base64 encoder and decoder, make a strong password with the password generator, or make unique ids with the UUID generator.
Frequently asked questions
Is my text or file uploaded?
No. The hashes are worked out in your browser, for text and for files, so nothing you type or open is sent to this website or anywhere else. The page does not even keep your text or your key: only your choice of input and output format is remembered on your device.
Is a hash the same as encryption?
No. Encryption can be undone with a key; a hash cannot be undone at all. A hash is a short fingerprint of the data: the same data always gives the same fingerprint, and a tiny change gives a completely different one. That makes hashes good for checking that a file was not damaged or changed, but they do not hide the data.
Why is MD5 called broken, and can I still use it?
Researchers can make two different files with the same MD5 hash, so MD5 must not be used where an attacker could gain from that, such as digital signatures or certificates. SHA-1 has the same problem. For simple checks against accidental damage, such as a file that downloaded incompletely, MD5 and SHA-1 still work, and many sites still publish them. When there is a choice, use SHA-256 or stronger.
Can I use these hashes to store passwords?
No. Plain hashes such as SHA-256 are made to be fast, which also lets someone try billions of guesses a second against a stolen list. Passwords should be stored with a slow, salted method made for the job, such as Argon2, bcrypt or scrypt, using your framework’s password functions.
Why does my hash not match the one I expected?
The usual reasons are an extra space or line break at the end of the text (a single new line changes every hash), a different text encoding (this page uses UTF-8 unless you choose hex or Base64 input), hashing the text when the other side hashed a file, or comparing different algorithms. Length helps: 8 hex characters is CRC32, 32 is MD5, 40 is SHA-1 or RIPEMD-160, 56 is SHA-224, 64 is SHA-256 or one of the other 256-bit hashes, 96 is SHA-384 and 128 is SHA-512, SHA3-512 or BLAKE2b. The comparison box checks every row at once.
What is an HMAC and when do I need the key box?
An HMAC mixes a secret key into the hash, so only someone who knows the key can make or check it. Web services use it to sign requests and webhooks. If you leave the key box empty you get a normal hash; type a key and every result becomes an HMAC with the same algorithm. CRC32, Keccak-256, BLAKE2b and BLAKE3 have no standard HMAC, so their rows show a dash while a key is set. The key is read as UTF-8 text.
What is the difference between SHA3-256 and Keccak-256?
Both come from the Keccak design, but they add different padding before hashing, so the same input gives different results. SHA3-256 is the version NIST standardized in FIPS 202. Keccak-256 is the earlier version that Ethereum adopted before the standard was final, and it is still what Ethereum uses for addresses and function selectors. If a hash is meant for Ethereum, use the Keccak-256 row.
Can I check a Subresource Integrity (SRI) value?
Yes. Paste the whole value from an integrity attribute, such as sha384- followed by the Base64 text, into the comparison box with the file loaded. It is read as Base64 and compared with the matching SHA-2 row. Choose Base64 as the output format to copy a hash in the same form.