Hash Generator
Compute SHA-1, SHA-256, SHA-384 and SHA-512 digests of text or a file, as hex or Base64. Runs in your browser.
How to use
- Under What do you want to hash?, choose Text or A file.
- For text, type or paste into the box. The digests update as you type. For a file, pick one with the file chooser. It is read into the page in your browser and is not uploaded.
- Choose Hex or Base64 under Output format. Tick Upper case hex if the checksum you are comparing against is written in capitals. Changing the format does not hash again.
- Press Copy beside the algorithm you need. To verify a download, compare the whole digest with the one the publisher gives, character by character.
Worked example
Type the three letters abc. The tool gives these hex digests:
| Algorithm | Digest |
|---|---|
| SHA-1 | a9993e364706816aba3e25717850c26c9cd0d89d |
| SHA-256 | ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad |
| SHA-512 | ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f |
These match the published test vectors for SHA-1 and SHA-2, which is a good way to check any hashing tool. Switch to Base64 and the SHA-256 digest becomes ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0=, the same 32 bytes written differently.
Now change one letter and type Abc. The SHA-256 digest becomes 06d90109c8cce34ec0c776950465421e176f08b831a938b3c6e76cb7bee8790b, which shares nothing recognisable with the first one. That sensitivity is what makes a hash useful for detecting change.
How it works
SHA-1, SHA-256, SHA-384 and SHA-512 belong to the Secure Hash Standard, FIPS 180-4. Each reads the input in fixed-size blocks, mixes them through many rounds of bitwise operations, and outputs a fixed-length digest of 160, 256, 384 or 512 bits. A good hash is one-way (you cannot recover the input from the digest), and it is collision resistant, meaning it is infeasible to find two different inputs with the same digest.
The page calls the browser's Web Crypto function SubtleCrypto.digest, so the maths is done by the browser's own tested code, not by script on this page. Text is encoded as UTF-8 first, so the same characters give the same bytes on every device. Web Crypto is only available on secure (HTTPS) pages. In a browser without it, the page switches its inputs off and says why.
SHA-1 is broken for collision resistance. In 2017 researchers produced two different PDF files with the same SHA-1 digest (the SHAttered attack), and NIST has planned to retire SHA-1 by 2030. It still appears in old checksums and in Git for historical reasons. Use SHA-256 or stronger for anything new. MD5 is not offered here because it has been broken for far longer.
Common mistakes and edge cases
- Hashing passwords for storage. A plain SHA hash is built to be fast, which helps attackers. Use a password hashing function made to be slow and salted, such as Argon2id, scrypt or bcrypt, as set out in the OWASP Password Storage Cheat Sheet.
- Treating a hash as a signature. A digest proves the bytes match the digest. It does not prove who published it. If the digest sits on the same compromised page as the download, an attacker changes both. Prefer a digest or signature from a separate trusted channel.
- Hidden characters. A trailing space or a different line ending changes the digest. A text hashed here may differ from the same file hashed with a command-line tool if the file ends with a line break and the text box does not.
- Comparing the wrong encoding. Hex and Base64 digests of the same data look nothing alike. Make sure both sides use the same one.
- Keyed use. To authenticate a message with a secret key, use HMAC, not a bare hash with the key pasted in front.
Frequently asked questions
Which algorithm should I pick?
SHA-256 is the usual choice. SHA-384 and SHA-512 are fine when a system asks for them. Use SHA-1 only to match an existing checksum.
Can a hash be reversed?
Not by calculation. Short or common inputs can still be found by guessing and hashing the candidates, which is why unsalted password hashes are weak.
Is my file uploaded?
No. The browser reads it into memory on your device and hashes it there. Very large files may be slow because the whole file is loaded.
Why does the page ask for a secure connection?
Browsers expose the Web Crypto API only in secure contexts, so it is unavailable on plain HTTP pages.
Is a longer digest always better?
Longer digests give more margin against collision attacks, but SHA-256 is already far beyond any practical attack.
Related tools
- Password Generator to create the secret you will protect with a password manager.
- Password Strength Checker to see why entropy, not a hash, measures a password.
- Base64 & URL Encoder/Decoder for the Base64 form of a digest.
- Hex Dump and File Inspector to look at the raw bytes behind a file.