How to generate a SHA-256 hash
- Type or paste text into the box, or switch to File and drop any file up to 512 MB.
- The SHA-256 hash (highlighted) and the four other common hashes appear as you type.
- Pick hex or Base64 output, and turn on HMAC if you need a keyed signature.
- Press Copy, or paste a published checksum into Compare to check a download.
SHA-256 at a glance
| Digest size | 256 bits (64 hex characters) |
|---|---|
| Published | 2001 (SHA-2 family, FIPS 180-2) |
| Designed by | NSA |
| Security | Secure: no practical attacks are known |
| Common uses | TLS certificates, code signing, Bitcoin, file integrity, API signatures |
SHA-256 is the most widely used member of the SHA-2 family, published by NIST in 2001. It processes data in 512-bit blocks through 64 rounds and produces a 256-bit digest. It secures TLS certificates, software signatures, package managers, and Bitcoin, whose proof of work hashes block headers with SHA-256 twice. No practical collision or preimage attack is known, so it is the default choice for integrity checks today.
SHA-256 examples
The SHA-256 of The quick brown fox jumps over the lazy dog is:
d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592
The SHA-256 of an empty input (zero bytes) is:
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
If you ever see the second value, the program hashed nothing, usually because a file path was wrong or a variable was empty. Change a single character of the input and the whole hash changes, which is what makes hashes good at detecting modified files.
Why your SHA-256 hash doesn't match
A hash is calculated from bytes, not from what you see on screen. Two inputs that look identical can produce different hashes:
- A trailing newline.
echo "abc" | sha256sumhashesabcplus a line break. Useecho -norprintf. - Line endings. Windows saves text with CRLF, macOS and Linux with LF, so the same text file hashes differently.
- Text encoding. This tool hashes text as UTF-8, the web standard. PowerShell strings and some Windows APIs use UTF-16.
- Hex or Base64 input. If your input is already bytes written as hex or Base64 (for example a key), set Input is to match.
- Letter case doesn't matter.
D7A8FBB3…andd7a8fbb3…are the same hash.
Check a file's SHA-256 checksum on your computer
The File tab works for most files. To check very large files, or to script it, use the built-in command on your system:
| System | Command |
|---|---|
| Windows (PowerShell) | Get-FileHash file.zip -Algorithm SHA256 |
| Windows (Command Prompt) | certutil -hashfile file.zip SHA256 |
| macOS | shasum -a 256 file.zip |
| Linux | sha256sum file.zip |
| Any (OpenSSL) | openssl dgst -sha256 file.zip |
| Text, macOS/Linux | printf '%s' 'your text' | sha256sum |
Generate SHA-256 in code
| Language | Code (UTF-8 text → hex) |
|---|---|
| Python | hashlib.sha256("text".encode()).hexdigest() |
| Node.js | crypto.createHash("sha256").update("text").digest("hex") |
| PHP | hash("sha256", "text") |
| C# (.NET 5+) | Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes("text"))) |
| Java | MessageDigest.getInstance("SHA-256").digest(text.getBytes(UTF_8)) |
For an HMAC, use hmac.new(key, msg, hashlib.sha256) in Python or crypto.createHmac("sha256", key) in Node.js.
HMAC-SHA-256: hashing with a secret key
A plain hash lets you compare a file with an expected digest. Anyone who can replace the file can compute a new digest. An HMAC (hash-based message authentication code, RFC 2104) also mixes in a secret key, so only someone who holds the key can produce the right value. Webhooks from payment and messaging services, signed API requests and JSON Web Tokens (HS256) all work this way. Turn on HMAC with a secret key, enter the key, and compare the result with the signature you received.
MD5 vs SHA-1 vs SHA-256 vs SHA-384 vs SHA-512
| Algorithm | Output | Hex length | Collision-resistant? | Use it for |
|---|---|---|---|---|
| MD5 | 128 bits | 32 | No (broken 2004) | Non-security checksums |
| SHA-1 | 160 bits | 40 | No (broken 2017) | Legacy compatibility only |
| SHA-256 | 256 bits | 64 | Yes | The default for integrity and signatures |
| SHA-384 | 384 bits | 96 | Yes | High-assurance and government systems |
| SHA-512 | 512 bits | 128 | Yes | Large files on 64-bit systems |
Passwords are different. All five are built to be fast, which helps attackers guess billions of passwords a second. Store passwords with Argon2id, bcrypt or scrypt, and use our password generator to create them.
Compare a download to the digest for the exact release
Start on the publisher's release page or in a manifest you trust. Find the row for your exact file, including its version, platform and archive format. A Windows ZIP and a Linux archive from the same release can have completely different checksums. If the manifest lists several algorithms, select SHA-256 only when that is the one next to the expected value you copied.
Load the downloaded archive in File mode before extracting it. Paste the digest from the matching row, excluding the filename and any punctuation printed beside the value. Choose the matching output encoding so you can compare like with like. If a published SHA-256 digest is a string of 64 hexadecimal characters, for example, comparing it to Base64 text visually only compares two spellings of the data.
When a result differs, first recheck the filename and version. Download it again from the official location if the transfer may have been interrupted. Keep the expected digest separate while you repeat the check. If the second download still differs, check the publisher's release notes for a replacement or report the mismatch with the filename, expected digest and observed digest. Avoid running the file while you are still investigating.
Know what the result establishes
The comparison connects the downloaded bytes to the expected value you supplied. A trustworthy expected value matters just as much as a correct calculation. For example, someone who can replace a download and edit a checksum displayed next to it can make those two values agree. When the publisher offers a signed release or a signed manifest, follow the publisher's signature verification instructions as well.
For a simple transfer between colleagues, you might receive the checksum in an internal release ticket and the file through a separate download channel. Compare the value before unpacking the file. For an automated release process, record the hash algorithm and expected output format in the manifest. This prevents a later reader from having to guess whether the characters are hex, Base64 or a shortened display value.
If a text fixture produces a different result from a file with the same visible text, compare the underlying bytes. Save the fixture in the expected encoding and check whether the editor appended a final newline or a byte order mark. If your application hashes a JSON request, capture the serialized test body as it was sent. Reserializing the same fields can change spacing, ordering or escaping and therefore change the digest.
Leave enough room in verification records for the entire digest. A table or terminal can wrap a long value across lines, and a report may show only the first few characters. Copy from the full manifest or command output when you need to check a match. An abbreviated value can help you recognize the right row, but it carries less information than the full digest.
Verify the package before unpacking it
If a vendor lists SHA-256 beside an installer, copy the digest for the installer itself. Hashing a file found inside an archive checks a different byte sequence and will produce a different value. For a package deployed to several machines, keep the expected 64-character hex digest alongside the supported version and file name in your release notes. Recompute it when the release artifact is rebuilt, since an updated timestamp or a different compressor can change the archive bytes even when the contents appear the same. If the package manager already verifies a signed manifest, check its reported verification status before adding a separate manual step. NIST Secure Hash Standard.
Comments 0
No comments yet.