What Is SHA-256? How to Generate a SHA-256 Hash and When to Use It

If you have ever downloaded software and seen a long string of letters and numbers next to the download button, with a note saying “verify the checksum”, you have probably met SHA-256 โ€” even if you did not know its name at the time.

That string is a fingerprint. It is 64 characters long, it looks random, and it has one job: to prove that the file you downloaded is exactly the file the publisher released, byte for byte, with nothing added, removed or changed along the way.

SHA-256 is the hash function most of the modern internet relies on for that job. It secures website certificates, it sits underneath Bitcoin, it checks software downloads, and it is the default answer whenever someone asks “which hash should I use?” This guide explains what it is, how it works, how to generate one in seconds, and where its limits are โ€” because even the best hash has jobs it should never be given.

What is SHA-256?

SHA-256 stands for Secure Hash Algorithm 256-bit. It is a hash function: you feed it any input โ€” a word, a sentence, a whole file โ€” and it produces a fixed-size output called a digest, or hash.

That output is always 256 bits long, written as 64 hexadecimal characters (the digits 0-9 and the letters a-f). It does not matter whether your input is one letter or a 4 GB video file: the hash is always exactly 64 characters. That fixed length is part of what makes hashes useful โ€” a tiny password and a huge installer both reduce to the same neat, comparable fingerprint.

SHA-256 is one of the SHA-2 family of hash functions, published in 2001. The “256” in the name is the size of the output in bits. There are larger members of the same family โ€” SHA-384 and SHA-512, for example โ€” but SHA-256 is the one you will meet most often, because 256 bits is already far more security than any practical attack can overcome, and the shorter output is easier to store, compare and display.

What does a SHA-256 hash look like?

Here are a few real examples. Every one of these was computed with Python’s standard hashlib library, not copied from a table, and you can reproduce them yourself with the generator linked at the end of this guide:

InputSHA-256 hash
(empty string)e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
hello2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
Hello185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
password123ef92b778bafe771e89245b89ecbc08a44a4e166c06659911881f383d4473e94f
abcba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
The quick brown fox jumps over the lazy dogd7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592

Three things are worth noticing. First, even the empty string has a hash โ€” there is no such thing as “no hash”. Second, the hash of hello and the hash of Hello have nothing in common, even though the inputs differ by a single capital letter. That avalanche effect is what makes a hash useful as a fingerprint: any change, however small, shows up immediately and completely. Third, the hash tells you nothing about the length of the input. abc and a whole sentence both produce 64 characters.

The three rules of SHA-256

SHA-256 behaves the same way every time, and those behaviours define what it is good for:

  1. The same input always gives the same hash. Type hello into any SHA-256 tool, on any computer, in any year, and you will get 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824. That determinism is the whole point of a checksum: two people can compare hashes without ever sharing the original file. If your hash matches the publisher’s hash, you have the same file. If it does not, something changed.
  2. You cannot reverse it. There is no “un-hash” button. Given only a hash, the only way to find the input is to guess inputs and hash them until one matches. For a long random input that is hopeless. For a short guessable one โ€” like password123 โ€” it is trivial, because that hash is already sitting in public lists of precomputed hashes. This is why a plain SHA-256 hash is not a safe way to store a password, as we will see below.
  3. It is fast โ€” and that is both a strength and a weakness. SHA-256 was designed to be quick to compute, and on modern hardware it is. That speed is a feature for checksums: you can hash a multi-gigabyte file in seconds. It is a flaw for password storage, where you want hashing to be deliberately slow so that guessing is expensive. Speed is not good or bad on its own โ€” it depends entirely on the job.

How to generate a SHA-256 hash

Option 1: Use a free online generator (fastest)

  1. Open the SHA-256 Generator on SoftTools.
  2. Type or paste your text.
  3. Click generate โ€” the 64-character hash appears instantly, ready to copy.

Everything runs in your browser, so the text you hash is never sent to a server or stored anywhere. One technical note: the tool uses the browser’s Web Crypto API, which needs a secure (HTTPS) page โ€” SoftTools is served over HTTPS, so it works there. That matters if you are hashing something private: with a client-side tool, your text never leaves your machine.

Option 2: From the command line (best for files)

For a file, the command line is usually quicker than any website, because you do not have to upload anything:

  • Linux: sha256sum filename โ€” prints the hash followed by the filename.
  • macOS: shasum -a 256 filename โ€” the same idea, through the built-in shasum tool.
  • Windows (Command Prompt): certutil -hashfile filename SHA256
  • Windows (PowerShell): Get-FileHash filename -Algorithm SHA256

Compare the output with the hash the publisher lists. They must match character for character. A single character different means the file is different โ€” do not install it, and download it again from the official source.

Option 3: In code

Every major language has SHA-256 built in. In Python it is three lines:

import hashlib
print(hashlib.sha256(b"hello").hexdigest())
# 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824

JavaScript in the browser uses crypto.subtle.digest(“SHA-256”, data) โ€” the same API the SoftTools generator uses. Java, Go, PHP, C# and Ruby all have it in their standard libraries too. If you are writing software that needs a checksum, you almost never need an extra dependency for SHA-256.

What SHA-256 is used for

Checking downloads. This is the most common everyday use. Software publishers list a SHA-256 hash next to each download. You hash the file you received and compare. If they match, the download was not corrupted and not tampered with in transit.

Finding duplicate or changed files. Two files with the same SHA-256 hash are, for all practical purposes, the same file. Backup tools, cloud storage and version control use this to spot duplicates and to notice when a file has changed.

Website and certificate security. SHA-256 is part of how TLS โ€” the padlock in your browser โ€” verifies that the certificate a website presents is genuine and has not been forged. It is also used inside digital signatures, where a document is hashed and the hash is signed, rather than signing the whole document.

Blockchains. Bitcoin uses SHA-256 twice over (so-called “double SHA-256”) in its mining process and in the way blocks link to each other. Each block contains the hash of the previous block, so changing any old transaction would change every hash after it โ€” which is what makes the chain tamper-evident.

Data integrity in storage and APIs. Databases, file systems and APIs hash records so that later reads can prove nothing was silently altered. A stored hash is a cheap tripwire: recompute it, compare, and you know immediately whether the data is intact.

SHA-256 vs MD5 vs SHA-1

If you need a hash today, which one should you pick? The short answer: SHA-256, unless you have a specific legacy reason to use something else.

MD5SHA-1SHA-256
Output size128 bits / 32 hex chars160 bits / 40 hex chars256 bits / 64 hex chars
Published199219952001
Known practical collision attacks?Yes โ€” since 2004Yes โ€” first demonstrated in 2017No
Safe for security use?NoNoYes
Still fine forNon-security fingerprints, duplicate detectionLegacy compatibility onlyFile checks, certificates, signatures, blockchains

MD5 and SHA-1 are both broken for security: researchers have demonstrated practical collisions โ€” two different inputs with the same hash โ€” for both of them. A collision in MD5 was used in 2009 to create a rogue SSL certificate that browsers trusted. SHA-256 has no known practical collision attack, and no one has come close. That is the whole difference, and it is decisive. Our MD5 guide explains MD5’s remaining non-security uses in detail โ€” for anything where trust matters, use SHA-256 instead.

How likely is a SHA-256 collision, really?

With 256 bits of output, there are 2^256 possible hashes โ€” a number with 77 digits. The birthday paradox means a collision becomes likely after roughly 2^128 tries, not 2^256, but 2^128 is still an absurd number: about 340 billion billion billion billion attempts. No computer, and no collection of computers, can make a dent in it. A random collision in SHA-256 is not something to plan for; it is something to ignore.

That is not a promise that SHA-256 will be safe forever โ€” cryptography advances, and a future breakthrough could change the picture, as it did for MD5 and SHA-1. But as of today, there is no practical attack, and SHA-256 remains the safe default. If you are choosing a hash for a new project, this is the one.

What SHA-256 is NOT

It is not encryption. Encryption is reversible: you encrypt with a key, you decrypt with a key, and you get the original back. A hash is one-way. There is no key and no way back. If you need to read the data again later, you need encryption, not a hash.

It is not a password store. Storing a plain SHA-256 hash of a password is not safe, because common passwords hash to values an attacker can look up in seconds โ€” password123 hashes to ef92b778bafe771e89245b89ecbc08a44a4e166c06659911881f383d4473e94f, and that value is already public. Passwords belong to purpose-built hashers that are deliberately slow and add a random salt automatically: bcrypt, scrypt or Argon2. SHA-256 is too fast for that job, by design.

It is not a random ID. A hash is derived from its input, so the same input always gives the same hash. A UUID, by contrast, is a fresh random value every time โ€” that is what you want for a database row or an order ID, where two records must never share an identifier by accident. Use a hash when you need determinism; use a UUID when you need a fresh unique value. Our UUID guide explains the difference in full.

It is not proof of who created a file. A matching hash proves the file was not changed since the hash was made. It does not prove who made the hash. If an attacker controls both the download and the hash listed next to it, they can replace both. Real trust comes from getting the hash from a separate, trusted place โ€” the publisher’s official site, a signed release, or a package manager โ€” not from the same page as the file.

Common mistakes

  1. Hashing the wrong thing. Hash the file’s contents, not its name, and not a screenshot of it. Renaming a file does not change its hash; changing one byte inside it does. On the command line, make sure you are pointing at the file you actually downloaded, in the folder you think it is in.
  2. Comparing hashes by eye. Two 64-character strings look identical at a glance even when they differ in one character. Copy both hashes and compare them with a tool, or paste them side by side and search for the difference. Better still, let a script compare them โ€” humans are bad at spotting a single changed hex digit.
  3. Ignoring whitespace and line endings. Hashing hello and hashing hello with a newline at the end give completely different results, because the inputs are different. Text files copied between Windows and Linux often pick up different line endings, which changes the hash even though the visible text looks the same. When a hash does not match, check for trailing spaces and line endings before assuming the file is corrupt.
  4. Using plain SHA-256 for passwords. As above: fast hashing plus guessable passwords equals a lookup table. If you are building anything that stores passwords, use bcrypt, scrypt or Argon2 โ€” never a plain hash, MD5 or SHA-256.
  5. Trusting a hash from the same source as the file. A checksum only helps if the expected hash comes from somewhere the attacker does not control. A hash on the same download page, the same server, or the same email as the file is worth very little on its own. Get it from the official site, a signed checksum file, or a package manager you already trust.

FAQs

  1. What is SHA-256? SHA-256 is a hash function that turns any input into a fixed 64-character hexadecimal fingerprint. The same input always gives the same hash, and even a one-character change produces a completely different hash. It is used to verify files, secure certificates and signatures, and underpin blockchains.
  2. How do I generate a SHA-256 hash? Paste your text into the free SHA-256 Generator on SoftTools and click generate, or hash a file from the command line โ€” sha256sum on Linux, shasum -a 256 on macOS, certutil -hashfile file SHA256 on Windows. In Python, hashlib.sha256(b”hello”).hexdigest() gives 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824.
  3. What is the difference between SHA-256 and MD5? SHA-256 produces a 256-bit (64-character) hash with no known practical collision attack; MD5 produces a 128-bit (32-character) hash with practical collisions demonstrated since 2004. MD5 is fine for non-security fingerprints, but SHA-256 is the safe choice for anything where trust matters.
  4. Can SHA-256 be reversed or decrypted? No. SHA-256 is a one-way function โ€” there is no key and no way to recover the input from the hash. The only way to find an input is to guess inputs and hash them until one matches, which is hopeless for any long or random input.
  5. Is SHA-256 safe to use for passwords? Not on its own. Plain SHA-256 is too fast, and common passwords hash to values that are already public. Use bcrypt, scrypt or Argon2 for password storage โ€” they are deliberately slow and add a random salt automatically.
  6. How do I verify a downloaded file with SHA-256? Hash the file you downloaded with sha256sum (Linux), shasum -a 256 (macOS) or certutil -hashfile (Windows), then compare the result character for character with the hash the publisher lists. If they match exactly, the file is intact; if even one character differs, do not use it โ€” download it again from the official source.

Conclusion

SHA-256 is the quiet workhorse of the modern internet: the fingerprint behind verified downloads, website certificates, digital signatures and blockchains. It is fast, deterministic, one-way, and โ€” unlike its predecessors MD5 and SHA-1 โ€” it has no known practical attack.

The rules for using it well are simple. Hash the file you actually received, compare the result character for character, get the expected hash from a source you trust, and never use a plain hash โ€” SHA-256 or otherwise โ€” to store a password.

Next time you need a checksum you can rely on, generate one in seconds with the free SHA-256 Generator on SoftTools โ€” and if you are comparing it with the older hashes, our MD5 guide explains exactly where MD5 still fits and where it does not.

SHA-256 is a general-purpose hash function. This guide is general information, not security advice for a specific system โ€” for high-stakes security decisions, follow your platform’s current guidance or speak to a qualified security professional.

Rahul

Rahul runs SoftTools from India. He builds free, private online tools that work entirely in your browser, and writes practical guides that explain everyday calculations and web tools in plain language.

← Back to all tools