What Is SHA-256? How Hashing Works, With Simple Examples
What a hash function does, why SHA-256 is used everywhere from downloads to Bitcoin, and why it is the wrong choice for storing passwords on its own.
SHA-256 is everywhere: in HTTPS certificates, software downloads, Git, and Bitcoin. Yet most explanations jump straight into bit operations. This guide explains what it does and when to use it, with examples you can try yourself.
What is a hash function?
A hash function takes any input, a word, a file or a whole hard drive, and produces a short, fixed-length "fingerprint" called a hash or digest.
SHA-256 (Secure Hash Algorithm, 256-bit) always produces 256 bits, written as 64 hexadecimal characters. For example, the SHA-256 hash of the word hello is:
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
Try it in the SHA-256 Hash Generator. You will get exactly the same result, on any computer, every time.
The four properties that make SHA-256 useful
- Deterministic. The same input always gives the same hash.
- Avalanche effect. Change one character, for example
hellotoHello, and the hash changes completely. There is no visible relationship between the two outputs. - One-way. You cannot work backwards from a hash to the input. The only way is to guess inputs and compare.
- Collision-resistant. Nobody has ever found two different inputs with the same SHA-256 hash, and doing so is far beyond today's computing power.
Hashing is not encryption
| Hashing | Encryption | |
|---|---|---|
| Reversible? | No | Yes, with the key |
| Output length | Fixed (64 hex characters for SHA-256) | Grows with the input |
| Used for | Checking integrity, fingerprints | Keeping data secret |
If you need to get the original data back, you want encryption, not a hash.
SHA-256 vs MD5 vs SHA-1 vs SHA-512
| Algorithm | Output | Status |
|---|---|---|
| MD5 | 128-bit (32 hex) | Broken: collisions can be made in seconds. Fine only for non-security checks. |
| SHA-1 | 160-bit (40 hex) | Broken: a practical collision was published in 2017. |
| SHA-256 | 256-bit (64 hex) | Secure and the most widely used today. |
| SHA-512 | 512-bit (128 hex) | Secure. Often faster on 64-bit processors. |
You can compare all of them side by side in the Hash Generator.
Common uses
- Verifying downloads. Software sites publish a SHA-256 checksum. If the hash of your download matches, the file was not corrupted or tampered with.
- Digital signatures and certificates. HTTPS certificates are signed over a SHA-256 hash of their contents.
- Git identifies every commit by a hash (SHA-1 by default, with SHA-256 support).
- Bitcoin uses SHA-256 for its proof-of-work and block identifiers.
- Deduplication. Storage systems detect identical files by comparing hashes.
How to check a checksum
- Copy the SHA-256 value published next to the download.
- Generate the hash of your copy. On Windows, run
certutil -hashfile file.zip SHA256. On macOS or Linux, runshasum -a 256 file.zip. - Paste both into the Hash Compare tool to check that they match exactly.
Should I store passwords with SHA-256?
Not on its own. SHA-256 is designed to be fast, so an attacker with a stolen database can test billions of guesses per second. Passwords should be stored with a slow, salted password-hashing function such as Argon2id, bcrypt or scrypt. Most web frameworks do this for you.
As a user, the best protection is still a long, unique password for every site. See our guide on creating a strong password you can remember.
Frequently asked questions
Can SHA-256 be decrypted? No. It is not encryption. "Reverse lookup" websites only work for short, common inputs they have already hashed and stored.
Is SHA-256 safe from quantum computers? Known quantum attacks would reduce its strength from 256 to about 128 bits, which is still considered secure.
Why is my hash different from someone else's for the same text? Usually because of invisible differences: a trailing space or line break, different capitalisation, or a different text encoding.