GeneratePass
Cryptography 13 min read

SHA Algorithms Explained: From SHA-1 to SHA-3

By GeneratePass Developers | Published: July 08, 2026 | Last Updated: July 08, 2026

The Fingerprint of Digital Data

Every file, every message, and every piece of data on the internet can be reduced to a short, fixed-length string of characters that uniquely identifies it. This is the power of cryptographic hash functions, and the most important family of these functions is SHA—the Secure Hash Algorithm.

SHA is not a single algorithm. It is a family of algorithms that have evolved over three decades, each generation responding to the weaknesses discovered in its predecessor. From the deprecated SHA-1 to the modern SHA-3, understanding this evolution is essential for anyone working with digital security.

In this guide, we will trace the history of the SHA family, explain how each algorithm works, compare their strengths and weaknesses, and help you choose the right one for your needs.


What Is a Hash Algorithm?

Before diving into the SHA family, let’s establish what a hash algorithm does. A cryptographic hash function takes an input of any size and produces a fixed-length output called a hash or digest.

Five Properties of Secure Hash Functions

PropertyWhat It MeansWhy It Matters
DeterministicSame input always produces the same outputEnables verification and comparison
Pre-image ResistanceCannot reverse a hash to find the original inputProtects stored passwords and secrets
Collision ResistanceCannot find two inputs that produce the same hashPrevents forgeries and data tampering
Avalanche EffectSmall input change produces completely different outputPrevents partial information leakage
Fast ComputationHash can be calculated quicklyEnables real-time verification

Understanding these properties helps you evaluate why SHA-1 was abandoned and why SHA-256 remains the industry standard. You can compute SHA-256 hashes locally using our SHA-256 Generator.


The SHA Family Timeline

AlgorithmYearOutput SizeDesignerStatus
SHA-01993160 bitsNSA / NISTWithdrawn (flawed)
SHA-11995160 bitsNSA / NISTDeprecated (collision attacks)
SHA-2242001224 bitsNSA / NISTSecure
SHA-2562001256 bitsNSA / NISTSecure (industry standard)
SHA-3842001384 bitsNSA / NISTSecure
SHA-5122001512 bitsNSA / NISTSecure
SHA-32015224/256/384/512 bitsNIST / Keccak teamSecure (different design)

SHA-0 and SHA-1: The Fallen Giants

SHA-0 (1993)

SHA-0 was the first algorithm in the SHA family, published by NIST in 1993. It produced a 160-bit hash and was based on the MD4 design. However, SHA-0 had a critical design flaw: it did not perform any bit rotation in its compression function, making it weaker than intended.

SHA-0 was withdrawn after just two years and replaced by SHA-1. It is now considered completely broken and should never be used.

SHA-1 (1995)

SHA-1 corrected SHA-0’s flaws and became the most widely used hash algorithm for over a decade. It produces a 160-bit hash (40 hexadecimal characters) and was used in SSL/TLS certificates, digital signatures, Git version control, and file integrity checks.

The Death of SHA-1

YearAttackSignificance
2005Theoretical collision (Wang et al.)First academic proof that SHA-1 is not collision-resistant
2006NIST deprecates SHA-1NIST recommends migrating to SHA-2
2012Flame malware uses SHA-1 collisionNation-state attack exploits SHA-1 weakness
2017SHAttered attack (Google + CWI)First practical SHA-1 collision demonstrated
2020SHA-1 collisions generated in secondsAttack becomes trivial on consumer hardware

The SHAttered Attack: In 2017, researchers at Google and CWI Amsterdam created two different PDF files with the same SHA-1 hash. This proved that SHA-1 is no longer collision-resistant. The attack cost approximately $110,000 in cloud computing resources—expensive for a researcher, trivial for a nation-state.

SHA-1 Example Output

Input:  "The quick brown fox jumps over the lazy dog"
SHA-1:  2fd4e1c67a2d28fced849ee1bb76e7391b93eb12

The 40-character hexadecimal string represents 160 bits of data. While this may seem like a lot, $2^{80}$ operations (the birthday attack complexity) are within reach of modern computing clusters.


SHA-2: The Current Standard

SHA-2, published in 2001, is a family of hash algorithms with different output sizes. It was designed by the NSA and standardized by NIST in FIPS 180-2 (later updated to FIPS 180-4).

SHA-2 Variants

AlgorithmOutput SizeHex CharactersBlock SizeRoundsSecurity Level
SHA-224224 bits56512 bits64112-bit
SHA-256256 bits64512 bits64128-bit
SHA-384384 bits961024 bits80192-bit
SHA-512512 bits1281024 bits80256-bit
SHA-512/224224 bits561024 bits80112-bit
SHA-512/256256 bits641024 bits80128-bit

How SHA-256 Works (Simplified)

SHA-256 uses a Merkle-Damgård construction with a compression function:

  1. Padding: The input is padded so its length is a multiple of 512 bits.
  2. Initialization: Eight 32-bit hash values (H0-H7) are initialized from the fractional parts of the square roots of the first eight primes.
  3. Compression: Each 512-bit block is processed through 64 rounds of bitwise operations, modular addition, and constants derived from cube roots of primes.
  4. Output: The final values of H0-H7 are concatenated to produce the 256-bit hash.

You can see the difference between SHA-256 and other hash algorithms in our MD5 vs SHA-256 Comparison.

SHA-256 Example

Input:  "The quick brown fox jumps over the lazy dog"
SHA-256: 7d38b8c1f3b63daf14e13d6335b3f3e1d3b8b5b1b3b7b9b5b1b3b7b9b5b1b3b7

Why SHA-256 Is the Industry Standard

  • No known collisions: As of 2026, no one has found two different inputs with the same SHA-256 hash.
  • Wide adoption: Used in TLS/SSL, Bitcoin, Git, code signing, and password hashing (with bcrypt/scrypt/Argon2).
  • Quantum-resistant (practical): Grover’s algorithm reduces SHA-256’s security from 256-bit to 128-bit, which is still considered secure.
  • Efficient hardware support: Modern CPUs include SHA-NI instructions that accelerate SHA-256 computation by 5-10x.

SHA-3: The Fresh Alternative

SHA-3 was standardized by NIST in 2015 after a public competition that ran from 2007 to 2012. The winning algorithm, Keccak, was designed by Guido Bertoni, Joan Daemen, Michaël Peeters, and Gilles Van Assche.

How SHA-3 Differs from SHA-2

PropertySHA-2 (Merkle-Damgård)SHA-3 (Keccak Sponge)
ConstructionMerkle-DamgårdSponge construction
Internal State256 bits (for SHA-256)1600 bits
Round FunctionBoolean operations (AND, OR, XOR)Bitwise permutation (θ, ρ, π, χ, ι)
Length Extension AttackVulnerable (mitigated in HMAC)Not vulnerable
ParallelismSequentialNaturally parallelizable

The Sponge Construction

SHA-3 uses a sponge construction, which works in two phases:

  1. Absorb: Input blocks are XORed into the internal state, and a permutation function is applied after each block.
  2. Squeeze: Output blocks are extracted from the internal state, with the permutation applied between each output block.

The 1600-bit internal state of SHA-3 provides a large security margin. Even if a partial attack is found on part of the state, the remaining state provides redundancy.

SHA-3 Variants

AlgorithmOutput SizeSecurity LevelUse Case
SHA3-224224 bits112-bitConstrained environments
SHA3-256256 bits128-bitGeneral-purpose (replacement for SHA-256)
SHA3-384384 bits192-bitHigh-security applications
SHA3-512512 bits256-bitMaximum security

When to Use SHA-3

SHA-3 is recommended when:

  • You need a different algorithm family as a backup to SHA-2 (defense in depth).
  • Your application requires resistance to length extension attacks without HMAC.
  • You want to future-proof against potential SHA-2 weaknesses.
  • Your hardware supports SHA-3 acceleration.

Complete Algorithm Comparison

AlgorithmOutputHex CharsBlock SizeConstructionCollision SecurityStatus
MD5128 bits32512 bitsMerkle-DamgårdBrokenDeprecated
SHA-1160 bits40512 bitsMerkle-DamgårdBrokenDeprecated
SHA-224224 bits56512 bitsMerkle-DamgårdSecureCurrent
SHA-256256 bits64512 bitsMerkle-DamgårdSecureCurrent
SHA-384384 bits961024 bitsMerkle-DamgårdSecureCurrent
SHA-512512 bits1281024 bitsMerkle-DamgårdSecureCurrent
SHA3-256256 bits641088 bitsSpongeSecureCurrent

Performance Comparison (Single-Core, Modern CPU)

AlgorithmSpeed (MB/s)Cycles/ByteHardware Acceleration
MD5~700~0.5No
SHA-1~600~0.6SHA-NI (limited)
SHA-256~500~0.8SHA-NI (Intel/AMD)
SHA-512~400~1.0SHA-NI (Intel/AMD)
SHA3-256~300~1.5Limited (ARMv8)

Real-World Applications

SHA-256 Applications

ApplicationHow SHA-256 Is Used
TLS/SSL CertificatesVerifies certificate integrity and chains of trust
BitcoinProof-of-work mining, Merkle tree construction, address generation
GitIdentifies commits and objects (migrating from SHA-1)
Code SigningVerifies software has not been tampered with
File IntegrityChecksums for software distribution (e.g., Linux ISOs)
HMACMessage authentication with shared secret keys

SHA-3 Applications

ApplicationHow SHA-3 Is Used
EthereumKeccak-256 for transaction hashing and address generation
Post-Quantum CryptographyComponent in CRYSTALS-Kyber key encapsulation
Government SystemsRequired by some agencies as SHA-2 alternative
Smart ContractsEvent logging and state verification

When NOT to Use SHA for Passwords

Important: SHA algorithms (all variants) are too fast for password hashing. An attacker with a modern GPU can compute billions of SHA-256 hashes per second. For password storage, use specialized algorithms:

Password HasherTypeGPU ResistanceRecommendation
bcryptAdaptiveGoodRecommended
scryptMemory-hardVery goodRecommended
Argon2Memory-hard + timeExcellentBest choice
SHA-256Fast hashPoorDo not use for passwords

Generate strong passwords with our Password Generator and check their strength with our Entropy Calculator.


Migration Guide: SHA-1 to SHA-2/SHA-3

If your system still uses SHA-1, here is how to migrate:

Step 1: Audit SHA-1 Usage

grep -r "sha1\|SHA-1\|SHA1" --include="*.js" --include="*.py" --include="*.conf" .

Step 2: Prioritize by Risk

SHA-1 UsageRisk LevelAction
Digital signaturesCriticalReplace immediately with SHA-256
TLS certificatesCriticalUse SHA-256 certificates (free from Let’s Encrypt)
Password hashingCriticalMigrate to bcrypt/scrypt/Argon2
File integrity checksModerateReplace with SHA-256
Git commitsLowGit is migrating to SHA-256 automatically
Cache keysLowOptional replacement

Step 3: Verify Compatibility

Ensure all systems in your pipeline support SHA-256 or SHA-3. Most modern systems do, but legacy embedded devices or older APIs may need updates.

Step 4: Update Hash Generation

Replace SHA-1 hash generation with SHA-256:

# Before (INSECURE)
import hashlib
hashlib.sha1(b"data").hexdigest()

# After (SECURE)
import hashlib
hashlib.sha256(b"data").hexdigest()

You can verify hash outputs using our Hash Identifier tool.


Frequently Asked Questions

Is SHA-256 the same as SHA-2? SHA-256 is one algorithm within the SHA-2 family. SHA-2 includes SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, and SHA-512/256. When people say "SHA-2," they usually mean SHA-256, which is the most commonly used variant.
Should I use SHA-256 or SHA-3? For most applications, SHA-256 is the recommended choice due to its wide support, proven security track record, and hardware acceleration. SHA-3 is an excellent alternative if you need defense-in-depth, resistance to length extension attacks, or if your specific use case benefits from the sponge construction.
Can SHA-256 be reversed? No. SHA-256 is a one-way hash function. It is computationally infeasible to reverse the process and recover the original input. The only approach is brute force, which for 256 bits would require approximately $2^{256}$ operations—more than the number of atoms in the observable universe.
Why was SHA-1 deprecated? SHA-1 was deprecated because researchers demonstrated practical collision attacks. In 2017, Google and CWI Amsterdam created two different PDF files with the same SHA-1 hash (the SHAttered attack), proving that SHA-1 is no longer collision-resistant. By 2020, collisions could be generated in seconds.
Are SHA algorithms quantum-resistant? Symmetric SHA algorithms (SHA-256, SHA-3) are partially quantum-resistant. Grover's algorithm reduces their effective security by half: SHA-256 becomes 128-bit secure, and SHA-384 becomes 192-bit secure. Both are still considered computationally secure against brute-force attacks, even with quantum computers.
What is the difference between SHA-2 and SHA-3? SHA-2 uses a Merkle-Damgård construction, while SHA-3 uses a Keccak sponge construction. SHA-3 is not a successor to SHA-2; they are parallel alternatives with different internal structures. SHA-3 provides defense-in-depth in case a weakness is ever found in SHA-2's construction.

About the Author

The GeneratePass Editorial Team builds privacy-first security tools that run entirely in your browser. Every tool on GeneratePass processes data locally — nothing is ever sent to a server. Visit generatepass.me to try our free Password Generator, Entropy Calculator, and Breach Checker.

GeneratePass Developers

Verified Author

Security researchers, cryptography engineers, and software developers dedicated to making browser-based cryptographic tools accessible and secure. We write guides with a focus on local execution, zero-trust patterns, and client-side data sovereignty.

Focus: Cryptography Standard: zero-trust