Tools Nimbus

SHA-1 vs SHA-256: what is the difference

Tools Nimbus is a free, no-signup developer toolkit that runs entirely in your browser, so your data is never uploaded to a server. SHA-256 is the safer choice for anything security-sensitive: its 256-bit digest has no known practical collision, while SHA-1's 160-bit digest was broken by a real collision in 2017 and NIST disallows it after 2030. Use SHA-1 only for non-security legacy checksums. Compare both free in the browser-based Hash Generator.

Last updated July 2026

The short answer

SHA-1 and SHA-256 are both cryptographic hash functions: they take any input and produce a fixed-size fingerprint. The practical difference is that SHA-1 is broken and SHA-256 is not. A hash function's whole job is that you can never find two inputs with the same output, and in 2017 researchers found exactly that for SHA-1. SHA-256, part of the newer SHA-2 family, has no such weakness and is the default you should reach for today. If you only remember one line: use SHA-256 (or SHA-384 / SHA-512) for anything where an attacker might benefit from a forgery, and treat SHA-1 as legacy-only.

Side by side

PropertySHA-1SHA-256
FamilySHA-1 (standalone)SHA-2
Digest size160 bits256 bits
Hex length40 characters64 characters
Collision resistanceBroken (practical collision found)~2^128 operations, no known collision
First public collision2017 (SHAttered)None
Status (as of 2026)Deprecated; NIST disallows after Dec 31, 2030Recommended baseline
Relative speedSlightly faster per byteSlightly slower, negligible in practice
Use for new work?No (legacy compatibility only)Yes

What they have in common

Both are one-way functions: you cannot run them backwards to recover the input from the digest, which is why hashes are used for integrity and fingerprinting rather than for hiding data. Both are deterministic (the same input always yields the same digest) and both show the avalanche effect, where changing a single bit of input flips about half the output bits. Both also produce a fixed-length result no matter how large the input is: SHA-1 always emits 40 hex characters and SHA-256 always emits 64. You can watch all of this directly by typing into the Hash Generator, which computes SHA-1, SHA-256, SHA-384, and SHA-512 side by side using your browser's Web Crypto API.

They share a design lineage too. Both use the Merkle-Damgard construction, processing the message in fixed-size blocks and chaining a running state forward. That shared structure is why both are vulnerable to length-extension attacks, covered further down, and why neither should be used as a bare message authentication code.

Why SHA-1 is considered broken

Security for a hash function is measured by how hard it is to find a collision: two different inputs that produce the same digest. For a 160-bit hash, a generic birthday attack needs about 2^80 operations, which was already within reach of well-funded attackers. In February 2017 a team from Google and CWI Amsterdam went further and published SHAttered, the first practical SHA-1 collision, producing two distinct PDF files with the same SHA-1 digest. Later work drove the cost down and demonstrated chosen-prefix collisions, which are the dangerous kind for forging certificates and signatures. Once a practical collision exists, an attacker can, in the worst case, get you to trust a malicious file that shares a legitimate file's hash. That is why browsers stopped accepting SHA-1 TLS certificates years ago, Git has been moving toward SHA-256 object hashing, and NIST formally retired SHA-1 in 2022 with a full disallow date of December 31, 2030.

SHA-256, by contrast, offers roughly 128-bit collision resistance, and no collision has ever been found. The gap is not incremental: 2^128 is astronomically beyond 2^80, and there is no known shortcut that weakens SHA-256 the way cryptanalysis weakened SHA-1.

Where SHA-1 still shows up safely

Broken for security does not mean useless everywhere. SHA-1 is fine when no attacker can control the input, because collisions have to be deliberately crafted; they do not happen by accident. Detecting accidental corruption in a download, deduplicating cache entries, or acting as a fast non-cryptographic fingerprint are all acceptable, and plenty of legacy systems still emit SHA-1 for these. The rule is simple: the moment an adversary could benefit from two inputs colliding, SHA-1 is the wrong tool. If you are verifying that a published binary was not tampered with, use the SHA-256 checksum the project provides, not its SHA-1 one.

The nuance both share: length-extension

Because both are Merkle-Damgard hashes, if you compute SHA-256(secret + message) and expose the digest, an attacker who does not know the secret can still append data and compute a valid digest for the extended message. This bites people who hand-roll authentication by concatenating a key with data. The fix is not to switch algorithms but to use HMAC (for example HMAC-SHA-256), which wraps the hash in a construction immune to length extension. Choosing SHA-256 over SHA-1 improves collision resistance; it does not by itself make a naive keyed-hash scheme safe.

Neither one is a password hash

A common mistake is storing user passwords as a plain SHA-256. Both SHA-1 and SHA-256 are designed to be fast, which is exactly wrong for passwords: an attacker with a stolen database can try billions of guesses per second, and identical passwords hash to identical values. Password storage needs a deliberately slow, salted algorithm such as bcrypt, scrypt, or Argon2. If you just need a strong secret to begin with, generate one locally with the Password Generator. For the broader picture of when to hash versus encrypt versus encode, see encoding vs encryption vs hashing.

How to choose in one line

Use SHA-256 (or SHA-384 / SHA-512) for anything where integrity matters against a real adversary: checksums you want to prove were not altered, digital signatures, certificate fingerprints, and content addressing. Reserve SHA-1 for legacy interoperability or non-security fingerprints, and never introduce it into new security-sensitive code. To generate and compare either digest in your browser without uploading a thing, open the Hash Generator; to encode binary for transport rather than fingerprint it, use the Base64 Encoder and Decoder. The full set of tutorials lives on the Tools Nimbus guides index.

Frequently asked questions

Is SHA-1 or SHA-256 more secure?+

SHA-256 is more secure. It produces a 256-bit digest with roughly 128-bit collision resistance and has no known practical collision. SHA-1 produces a 160-bit digest and was broken by a real, demonstrated collision in 2017 (the SHAttered attack), so it should not be used for any new security purpose. For signatures, certificates, and tamper checks, choose SHA-256 or stronger.

Is SHA-1 still safe to use in 2026?+

Not for security. Practical collisions against SHA-1 have existed since 2017, and NIST has deprecated it and plans to disallow it entirely after December 31, 2030. SHA-1 is only acceptable for non-security tasks where an attacker cannot craft the input, such as detecting accidental corruption or deduplicating cache entries. For anything an attacker could exploit, use SHA-256.

What is the difference between SHA-1 and SHA-256?+

SHA-1 outputs a 160-bit digest (40 hex characters) and belongs to the older SHA-1 standard; SHA-256 outputs a 256-bit digest (64 hex characters) and belongs to the SHA-2 family. The larger output and stronger internal design give SHA-256 far higher collision resistance. In practice SHA-1 is broken and deprecated, while SHA-256 is the modern default.

Is SHA-256 slower than SHA-1?+

Slightly, but it rarely matters. On modern CPUs SHA-1 can be somewhat faster per byte, yet both hash hundreds of megabytes per second and the difference is dwarfed by disk and network time in almost every real workload. The tiny speed gain is never a good reason to pick the broken algorithm over the secure one.

Can I use SHA-256 to hash passwords?+

No, not on its own. A raw SHA-256 is far too fast, letting attackers guess billions of candidates per second, and identical passwords produce identical digests. Real password storage uses a purpose-built, deliberately slow algorithm such as bcrypt, scrypt, or Argon2 with a unique per-user salt. SHA-256 is for integrity and fingerprints, not password storage.

Should I use SHA-1 for file checksums?+

Prefer SHA-256. SHA-1 will still detect accidental corruption during a download, but if an attacker could tamper with the file and the checksum, SHA-1's known collisions make it unsafe. Since SHA-256 costs essentially nothing extra and is what most projects now publish, use it for any checksum meant to prove a file was not altered.

Try these browser-based tools mentioned in this guide. Everything runs locally, so your data never leaves your device.