MergeDoc

SHA-256 Hash Explained: What It Is and When to Use It

If you have ever downloaded software and seen a long string of letters and digits next to the link labelled "SHA-256 checksum", you have met a hash. It looks like noise, but it is one of the most useful ideas in computing: a short fingerprint that stands in for data of any size.

This post explains what SHA-256 does, the properties that make it useful, what it is not good for, and how to try it in a few seconds without installing anything.

What a hash function is

A hash function takes any input and returns a fixed-size output called a digest. SHA-256 is part of the SHA-2 family and always returns 256 bits. Written in hexadecimal, that is 64 characters, because each hex character represents 4 bits.

Here are real digests, so you can check any tool against them:

  • The empty string hashes to e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.
  • The text abc hashes to ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad.
  • The text hello hashes to 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824.

The output is always 64 characters, whether the input is one letter or a ten-gigabyte video.

The properties that make hashes useful

  • Deterministic. The same input always gives the same digest, on any machine.
  • Fixed size. Easy to store and compare.
  • One-way. You cannot compute the input from the digest, except by guessing inputs and hashing them.
  • Avalanche effect. A tiny change produces a completely different digest. hello and Hello share almost nothing: the second begins 185f8db3, while the first begins 2cf24dba.
  • Collision resistant. It is infeasible, as far as is publicly known, to find two different inputs with the same SHA-256 digest.

The avalanche property is what makes hashes good for detecting tampering. You cannot make a "small" edit to a file and keep a similar-looking hash.

How to generate a hash

  1. Open the Hash Generator.
  2. Type or paste your text into the box.
  3. The four digests appear together: SHA-1 (40 hex characters), SHA-256 (64), SHA-384 (96) and SHA-512 (128).
  4. Click Copy beside the one you need.

The tool uses your browser's built-in Web Crypto API, the same primitives websites use for their own security. The text is converted to UTF-8 bytes before hashing, which matches what most programming languages do by default. Nothing is uploaded.

Two limits: it hashes text, not files, and it offers the SHA family only, not MD5. Since it works on exactly what is in the box, a trailing newline you paste in changes the answer. Try it: hello and hello followed by a new line give different digests (the second starts 5891b5b5).

Where hashes are used

  • Verifying downloads. Publishers post the expected hash; you compute your own and compare.
  • Detecting changes. Hash a document today and again next month. If the digests differ, the contents changed.
  • Deduplication. Files with identical hashes are the same file, so storage systems keep one copy.
  • Digital signatures. Signing a hash of a message is far cheaper than signing the whole message.
  • Content addressing and caches. Build tools name files by hash so browsers fetch new versions automatically.
  • Integrity checks in APIs. Webhooks often sign payloads using a keyed variant (HMAC), which adds a secret to the idea.

SHA-1 versus SHA-256 and the longer variants

SHA-1 produces 160 bits and was widely used for years. In 2017, researchers publicly demonstrated a practical collision for it, and it has been deprecated for security-sensitive uses since. It still appears in older systems and in some non-security contexts, which is why the tool shows it. For anything new, pick SHA-256 or longer.

SHA-384 and SHA-512 are longer members of the SHA-2 family. They are not "more secure" in a way most applications need; SHA-256 is already considered strong. People choose them for compatibility with a specification or, on some 64-bit hardware, for speed.

Hashing is not encryption

This is the most common confusion. Encryption hides data and can be undone with a key. A hash cannot be undone. So "decrypt my SHA-256" is a meaningless request, although websites that offer to do it are really just looking the hash up in a table of known inputs. That works only for short or common strings, like simple passwords.

If you want a message only a recipient can read, use encryption: see AES-256 text encryption explained and the Text Encryptor.

Hashing passwords: do not do it with plain SHA-256

It is tempting to hash a password with SHA-256 and store the result. The problem is speed. SHA-256 is built to be fast, which means an attacker who steals a table of hashes can test enormous numbers of guesses. Two defences are essential: a unique salt per password so identical passwords do not share a digest, and a deliberately slow algorithm. Use bcrypt, scrypt, Argon2 or PBKDF2 for that job. The password side of the story is in strong passwords vs passphrases.

Where current tools fall short

Many hash websites send your input to a server, which is a bad habit when the text is a token, a key or a snippet of customer data. Others bury the hash in ads, offer only one algorithm at a time, or pair it with a "crack this hash" feature that encourages bad practice. A client-side generator computes the digest in your tab so the text stays with you.

The caveat of this one is scope. It does text only. If you need to checksum a large file, MD5, or keyed HMACs, use your terminal or a library.

Everyday use cases

  • Comparing two long strings. Hash both and compare 64 characters instead of reading two paragraphs.
  • Checking a pasted API payload. Confirm you have the exact same text a colleague has.
  • Learning how hashes behave. Change one letter and watch every character change.
  • Creating a stable identifier from a string for a cache key or test fixture.
  • Matching a published value for a text-based test vector.

Working through a real check

Here is a small exercise that makes hashing concrete. Open the Hash Generator and type hello. Copy the SHA-256 value. It should start 2cf24dba and end 9824. Now change the first letter to a capital, Hello. The new value starts 185f8db3 and nothing else lines up. You changed one bit of input out of forty and about half of the output bits flipped.

Next, add a space at the end of hello. Different again. Hashes cannot tell you that two inputs are "almost the same", only whether they are identical. That is why they are a precise equality test and a poor similarity test. If you want to see how much two documents differ, use a diff, such as Text Diff, instead.

Now imagine a download page that lists a SHA-256 value for an installer. After you download the file you compute its hash with your operating system's command line tools and compare the result with the published one. If the two strings match exactly, the file you received is the file they published. If one character differs, discard the download. This protects against corruption and, if the hash was published on a separate trustworthy page, against tampering.

The same logic works for text you want to prove has not changed: store the digest now, recompute it later, and compare.

Tips and mistakes to avoid

  • Mind invisible characters. Spaces and newlines change the output.
  • Remember encoding. Different encodings of the same visible text produce different hashes.
  • Compare the whole digest. Do not trust the first few characters alone.
  • Never rely on a hash to hide secrets that are short or guessable.
  • Prefer SHA-256 or above for anything where security matters.
  • Uppercase and lowercase hex are the same. ABC and abc as hex digits represent identical values, so differences in case are just formatting.

Related reading

To pair hashing with real secrecy, read AES-256 text encryption explained. For identifiers rather than fingerprints, see UUID v4 explained. More utilities sit under developer tools.

Advertisement

Frequently asked questions

What is a SHA-256 hash?
It is a fixed-length fingerprint of some input. Whatever you feed in, a word or a whole book, SHA-256 returns 256 bits, shown as 64 hexadecimal characters. The same input always gives the same output, and you cannot work backwards from the output to the input.
How do I generate a SHA-256 hash of a string online?
Open the [Hash Generator](/hash-generator), type or paste your text, and the SHA-1, SHA-256, SHA-384 and SHA-512 hashes appear together. Click Copy next to the one you need. The text is hashed in your browser and not sent anywhere.
Is hashing the same as encryption?
No. Encryption is reversible with the right key; hashing is designed to be one-way. If you need to get the original back, use encryption, such as the [Text Encryptor](/text-encryptor). If you only need to check whether two things match, a hash is the right tool.
Should I store passwords as plain SHA-256 hashes?
No. SHA-256 is fast by design, which helps attackers who guess billions of passwords. Password storage should use a slow, salted algorithm built for the job, such as bcrypt, scrypt, Argon2 or PBKDF2.
Why do I get a different hash from another tool for the same text?
Almost always the input differs by an invisible character. A trailing newline, a space, different line endings or a different text encoding changes the hash completely. This tool hashes the exact characters you typed, encoded as UTF-8.
Can this tool hash a file or compute an MD5?
No. It hashes text only, and offers SHA-1, SHA-256, SHA-384 and SHA-512. For file checksums, use your operating system's built-in command line tools.

Tools mentioned

More in Developer Tools

Related posts