Hash Generator

MD5, SHA-1, SHA-256 and SHA-512 for any text or file, computed in the tab.

Input

0 bytes
No file selected

Text is encoded as UTF-8 before anything is computed. There is no encoding selector, because a digest is taken over bytes: the same sentence saved as Latin-1 produces a different digest from the same sentence saved as UTF-8, and only one of them will match a published value.

Digests

  • SHA-256
  • SHA-384
  • SHA-512
  • SHA-1

SHA-256 is written as 64 hex characters, SHA-384 as 96, SHA-512 as 128 and SHA-1 as 40. All four are recomputed on every change, so the copy buttons always return what you can see.

MD5

128 bits, kept for old checksum files
  • MD5

MD5 collisions can be built on purpose in seconds, so a matching MD5 digest is not evidence about anything an attacker had a hand in. It still catches a truncated download or a failing disk, which is what most published MD5 files were for. The browser's crypto API has never offered MD5, so this row is computed by a function written out on this page instead.

Compare two strings

Both boxes are hashed with SHA-256 and the two digests are compared. That is useful for two pieces of text — a line before and after an edit, the same field from two records. Checking a downloaded file against a published digest is a different job: hash the file above, then compare the characters yourself. This panel will not do that comparison for you.

Output

Both switches change the text on screen and in the clipboard. Neither touches the digest itself, so a formatted digest still compares equal to an unformatted one once the colons are gone.

Good practice

  • A digest proves the bytes, not the sender. If the page publishing the digest was altered, the digest was altered with it.
  • Use SHA-256 for anything adversarial. SHA-1 and MD5 are for spotting accidents, not for signing.
  • Do not store passwords this way. Speed is the whole point of SHA-256, and speed is the wrong property for a password hash. Use bcrypt, scrypt or Argon2.
  • Mind the line endings. A digest is taken over bytes, so a text file saved with Windows line endings will not match the same text saved with Unix ones.

A digest cannot be reversed and is not encryption. Change one byte of the input and roughly half the output bits flip, which is what makes a match worth something: it says the two byte streams are identical. It says nothing about where either of them came from, and nothing about whether the file is safe to open.

Two digests are identical or unrelated

Change one character of the input and roughly half the output bits flip, with no visible relationship to what changed. There is no such thing as a digest that is nearly right: editing a single digit in a paragraph produces a value that shares no more with the original than two unrelated files would. Every function here behaves that way, and it is the property that makes a digest worth comparing at all.

It also settles how much of one you need to look at. Because there is no gradient to exploit, the question is only how many bits you are checking and what it would cost someone to produce a different input with the same prefix:

SHA-256 as 64 hex characters, compared in full
        256 bits   a colliding pair needs ~2^128 work   not reachable

      first 32 hex characters only
        128 bits   a colliding pair needs ~2^64 work    out of reach

      first 16 hex characters only
         64 bits   a colliding pair needs ~2^32 work    one machine, minutes

      first 8 hex characters only
         32 bits   a colliding pair needs ~2^16 work    instant, on a laptop

      The cost is the square root of the space rather than the space itself,
      because a colliding pair is found by generating both halves at once.

That last line is the birthday bound, and it is the reason a truncated digest is weaker than the characters suggest. Dropping half of a SHA-256 does not halve its strength — it squares it. For spotting an accidental difference between two files, a short prefix is plenty and is what most checksum displays show. For standing up to someone who wants to deceive you, the full value is the minimum, and the comparison has to be against a value you got from somewhere other than the file itself.

What a match proves

A digest answers one question: are these two byte streams identical. Everything else people read into it is either a second question or an assumption. Match the published digest and you know the file arrived intact and is the file they hashed — not that the bytes are harmless, and not that the page you read the digest from belonged to them. Those are separate claims, and they need separate evidence: a signature, a second domain, a release page you reached through something you already trust.

This is where the difference between the functions stops being academic. MD5 and SHA-1 still detect accidental damage perfectly well — a truncated download, a corrupted disk, a file that did not finish copying all differ from the original. What they cannot do is resist someone constructing two different files with the same digest on purpose, which is a thing that has been done for both. If the only adversary you have is a flaky network, either is fine. If a published checksum is standing between you and a tampered installer, it has to be SHA-256 or better, from a source you trust independently of the file.

Why the same text does not always hash the same

Most disagreements about digests are not about the function. They are about bytes you cannot see. A text file has its own line endings, often a byte-order mark at the front, and possibly an encoding that is not UTF-8, so copying its contents into a text box and hashing the file both produce valid digests of different inputs. Opening a file and re-saving it can change the trailing newline, which is a byte, and one byte is enough.

Unicode adds a subtler version. A character with an accent can be stored as a single code point or as a base letter followed by a combining mark, and the two are different bytes that render the same on screen. Nothing about either form is wrong — they are both valid Unicode — but they are not the same input, and hashing does not normalise. When two values that look identical refuse to match, the answer is usually at the byte level rather than in the algorithm: a trailing space, a carriage return, a non-breaking space where a normal one was expected.

Fast is the wrong property for a password store. Every function here is built to run at speed on cheap hardware, which is precisely what an attacker doing billions of guesses a second needs. Password hashing wants the opposite: an algorithm that is deliberately slow and memory-hungry, so that each guess costs something and the cost can be raised as hardware improves. bcrypt, scrypt and Argon2 are the three to look at, and SHA-256 with a salt in front of it is not one of them.

Which one to reach for

SHA-256 is the default because it is the one everybody else checks. Release pages, package indexes and container registries publish it, so a value computed here has something to compare against — a stronger function with nothing to match is not more useful. SHA-512 is not stronger in any way that matters for a file digest; on 64-bit hardware it is often faster, because its internal operations line up with the register width, and that is the whole of the advantage.

MD5 survives for the same reason SHA-1 does: published digests for both still exist, and old download pages have not been rewritten. Reading them is fine. Producing a new one to publish is not, and neither is building anything that depends on a collision being hard. Where several files need hashing at once, BLAKE3 is the one designed for it and will outrun everything else in the table on the same machine.

Two adjacent tools cover the cases this one does not. When two files differ and you want to know where rather than whether, the Diff Checker marks the lines that disagree. When the job is naming something so that two things cannot collide, the UUID Generator is the tool built for that, and it needs no secret to do it.

Reference

What each digest length buys

AlgorithmDigestBlock sizeWhere you meet itSafe against tampering
MD5128-bit (32 hex)512-bitChecksum files and old download pagesNo
SHA-1160-bit (40 hex)512-bitGit object names, legacy signatures and certificatesNo
SHA-256256-bit (64 hex)512-bitTLS certificates, release digests, package indexesYes
SHA-384384-bit (96 hex)1024-bitTLS cipher suites and some government profilesYes
SHA-512512-bit (128 hex)1024-bitFile digests and 64-bit toolingYes
SHA3-256256-bit (64 hex)1088-bit rateNewer protocols that want a construction unlike SHA-2Yes
BLAKE2bup to 512-bit (128 hex)1024-bitArgon2, libsodium and Python hashlibYes
BLAKE3256-bit (64 hex)512-bitb3sum and build tools that hash many files at onceYes
CRC3232-bit (8 hex)Not block-basedZIP and gzip integrity checks, PNG chunksNo

Length is doing all the work in this table: the rows that are still trusted have room to spare, and the rows kept for compatibility are the short ones. MD5 and SHA-1 are listed because published digests for them still exist, not because anything new should be built on them.

A digest is a replacement for the input, not a measurement of it: text of any length comes out as the same fixed number of bits. Extra length does not make a function better at saying where the bytes came from; it buys collision resistance. An n-bit digest has 2^n possible values, so a brute-force hunt for a colliding pair costs roughly the square root of that. MD5's 128 bits were never going to hold; SHA-256's 256 still have room.

SHA-256 is the default because it is the one everybody checks. It ships with every platform, and release pages and package indexes publish it, so a digest you compute has something to compare against. SHA-512 is not stronger where it matters, though it is often faster on 64-bit hardware. SHA-384 runs the same engine as SHA-512 from a different starting value, so it is not a truncation of SHA-512.

SHA-2 uses the Merkle-Damgård construction, which hands out its final state as the digest: given a digest and the message length, someone can work out the digest of that message with extra bytes appended, without seeing the message. Anything keyed on SHA-2 needs HMAC. SHA-3 is a sponge and has no such flaw. And since every function here is built for speed, none belongs in a password store.

Questions

Digests, answered plainly

Should I hash passwords with SHA-256?

No. SHA-256 is built to run fast on cheap hardware, which is exactly the property a password hash must not have: a single GPU works through billions of candidate passwords a second. Password hashes want to be slow and memory-hungry on purpose — bcrypt, scrypt and Argon2 are the three to look at, and every language has a maintained library for at least one of them.

Is MD5 still usable for anything?

For catching accidental damage, yes, and that is what it is doing on this page. Two files that should be identical but are not will almost certainly hash differently, and a truncated download is obvious. For anything where someone might want to deceive you, no: a collision can be built for a chosen pair of files, so an MD5 that matches is not proof that the file is the one that was published.

How do I check a download from a terminal?

On macOS and most Linux systems: shasum -a 256 archive.zip, or sha256sum archive.zip where coreutils is installed. On Windows: certutil -hashfile archive.zip SHA256, or Get-FileHash archive.zip in PowerShell. Compare the result with the published digest character by character; a single difference in case does not matter, but a single difference in a digit does.

Why do two strings that look identical produce different digests?

The usual culprits, in order of frequency: a trailing newline at the end of one and not the other, Windows line endings against Unix ones, and a non-breaking space where a normal space was expected. Rarer but real is Unicode normalisation — the letter é can be stored as one code point or as an e followed by a combining accent, and the two are different bytes that look the same on screen.

What does the file button actually read?

The raw bytes of the file, exactly as they sit on disk. That is why opening a text file, copying its contents and pasting into the box above will usually produce a different digest: the file has its own line endings, often a byte-order mark, and possibly an encoding that is not UTF-8. For verifying a download, always use the file button rather than the text box.

Does any of this go anywhere?

Nothing is sent. The SHA rows come from the browser's own Web Cryptography API, which has no network access at all, and the MD5 row is a function written out in this page's JavaScript. If you keep a network panel open while you paste a document into the box, you will see it stay empty.

Why does echo give a different hash from printf for the same text?

echo appends a newline to whatever you hand it, and a newline is a byte. printf '%s' "text" does not, so the two commands feed different input to the same function and are supposed to disagree. Use echo -n and the digests will match. When a digest you computed will not match a published one, check for a trailing byte before you suspect the file.

Can I shorten a hash and keep the first 16 characters?

You can, and what you lose is not proportional to the characters you drop. Sixteen hex characters is 64 bits, which is still plenty for spotting an accidental difference between two files, and nowhere near enough for anything an attacker is trying to fake: collision strength falls to about 32 bits by the birthday bound, which one machine can search. Where a truncation is legitimate it is defined by the format rather than chosen by hand, and the full value is still checked somewhere.

If a publisher lists a checksum, does that mean the file is safe?

It means the file you have is the file they hashed, and nothing more. A digest says nothing about what the bytes do: a correctly hashed installer can still carry something you would not want to run. The list is only as trustworthy as the page it sits on, which is why the same digest published on a second domain, or signed with a key you already hold, is worth more. Match the digest first, then decide about the file on its own merits.