SHA-1 Hash Generator

Generate and verify SHA-1 hashes with this online cryptographic tool

Security Notice

SHA-1 is considered cryptographically broken and unsuitable for security applications. For security-critical purposes, use SHA-256 or SHA-512 instead.

Output Format

Advanced Options

HMAC-SHA1 uses a secret key to generate a more secure hash for authentication
Error message
Copied!

SHA-1 Hash Visualization

Cryptographic Strength:
Weak - Not recommended for security applications
Hash Length:
160 bits (20 bytes / 40 hex characters)
Collision Resistance:
Low (practical collisions demonstrated)

What is SHA-1?

SHA-1 (Secure Hash Algorithm 1) is a cryptographic hash function designed by the National Security Agency (NSA) and published by the National Institute of Standards and Technology (NIST) in 1995. It produces a 160-bit (20-byte) hash value typically rendered as a 40-character hexadecimal number.

Historical Context

SHA-1 was developed as an improvement to the earlier MD5 algorithm, which had begun showing signs of weakness. For many years, SHA-1 was widely used across the internet for security applications including:

  • Digital signatures and certificate authorities in SSL/TLS
  • Version control systems like Git
  • Data integrity verification
  • Various authentication protocols

However, theoretical weaknesses were identified in SHA-1 as early as 2005. By 2017, researchers from Google and CWI Amsterdam demonstrated the first practical collision attack, creating two different PDF files with identical SHA-1 hashes. This milestone, known as the "SHAttered" attack, definitively proved SHA-1's insecurity for cryptographic applications.

SHA-1 is No Longer Secure

As of 2025, SHA-1 is considered cryptographically broken. Major browsers no longer accept SSL certificates signed with SHA-1, and security standards have deprecated its use. For security applications, newer algorithms like SHA-256 or SHA-3 should be used instead.

Technical Details: How SHA-1 Works

SHA-1 processes input data in blocks of 512 bits (64 bytes) and maintains a 160-bit internal state. Here's a simplified overview of the algorithm:

1. Message Padding

Before processing begins, the input message is padded so that its length is congruent to 448 modulo 512. This is achieved by appending a single '1' bit followed by the necessary number of '0' bits. Then, a 64-bit representation of the original message length is appended, making the total padded message length a multiple of 512 bits.

2. Initialize Hash State

SHA-1 begins with five 32-bit constants as the initial hash values:

h0 = 0x67452301
h1 = 0xEFCDAB89
h2 = 0x98BADCFE
h3 = 0x10325476
h4 = 0xC3D2E1F0
            

3. Process Message in Blocks

For each 512-bit block of the padded message:

  1. Split the block into sixteen 32-bit words (W[0] through W[15])
  2. Extend these 16 words into 80 words by setting W[i] = (W[i-3] XOR W[i-8] XOR W[i-14] XOR W[i-16]) <<< 1 for i from 16 to 79, where <<< denotes a left circular shift
  3. Initialize the five working variables:
    a = h0, b = h1, c = h2, d = h3, e = h4
                        
  4. Perform the main compression loop with four distinct rounds (20 steps each):
    for i from 0 to 79:
        if 0 ≤ i ≤ 19:
            f = (b AND c) OR ((NOT b) AND d)
            k = 0x5A827999
        else if 20 ≤ i ≤ 39:
            f = b XOR c XOR d
            k = 0x6ED9EBA1
        else if 40 ≤ i ≤ 59:
            f = (b AND c) OR (b AND d) OR (c AND d)
            k = 0x8F1BBCDC
        else if 60 ≤ i ≤ 79:
            f = b XOR c XOR d
            k = 0xCA62C1D6
    
        temp = (a <<< 5) + f + e + k + W[i]
        e = d
        d = c
        c = b <<< 30
        b = a
        a = temp
                        
  5. Update the hash values:
    h0 = h0 + a
    h1 = h1 + b
    h2 = h2 + c
    h3 = h3 + d
    h4 = h4 + e
                        

4. Final Output

The final 160-bit hash value is produced by concatenating the five 32-bit words:

SHA-1(message) = h0 || h1 || h2 || h3 || h4
            

Security Vulnerabilities

Collision Attacks

A collision occurs when two different inputs produce the same hash value. For secure cryptographic hash functions, finding such collisions should be computationally infeasible. However, SHA-1 has proven vulnerable to collision attacks:

  • 2005: Theoretical attacks by Wang et al. reduced the collision resistance from 2^80 to 2^69 operations
  • 2017: Google and CWI Amsterdam's "SHAttered" attack demonstrated the first practical collision, requiring approximately 2^63 SHA-1 computations
  • 2020: The "SHA-1 is a Shambles" attack demonstrated a chosen-prefix collision, allowing attackers to create collisions between arbitrary files

The SHAttered Attack

In 2017, researchers created two different PDF files with the same SHA-1 hash. This demonstrated that attackers could potentially create malicious files (like malware) that have the same hash as legitimate files, undermining security systems that rely on SHA-1 for verification.

You can see the collision demonstration at shattered.io.

Length Extension Attacks

Like other Merkle–Damgård construction hash functions, SHA-1 is vulnerable to length extension attacks. If an attacker knows the hash H(M) of a message M, they can compute H(M || padding || N) for any additional data N without knowing the original message M. This vulnerability affects applications that use SHA-1 in naive message authentication schemes.

Current Status and Recommendations

Deprecation Timeline

  • 2011: NIST formally deprecated SHA-1 for digital signatures
  • 2014: Major browsers announced plans to stop accepting SHA-1 SSL certificates
  • 2016: Browser vendors began phasing out support for SHA-1 certificates
  • 2017: First practical collision attack demonstrated
  • 2020: All major browsers fully rejected SHA-1 certificates

Where SHA-1 Is Still Used

Despite its known vulnerabilities, SHA-1 remains in use in some legacy systems and applications:

  • Git: The version control system Git still uses SHA-1 for object identification, although there's an ongoing migration to SHA-256
  • Legacy systems: Older software and hardware that cannot be easily updated may still use SHA-1
  • Non-security applications: Applications where collision resistance is not a security requirement

Recommended Alternatives

For security-critical applications, the following alternatives are recommended:

  • SHA-256 or SHA-512: Members of the SHA-2 family with significantly stronger security properties
  • SHA-3: The newest member of the SHA family, based on a completely different design that addresses weaknesses in previous hash functions
  • BLAKE2 or BLAKE3: Modern hash functions offering high security and exceptional performance

HMAC-SHA1

HMAC (Hash-based Message Authentication Code) with SHA-1 creates HMAC-SHA1, which is a construction used for message authentication. The HMAC construction largely mitigates the collision vulnerabilities of SHA-1 when used for message authentication purposes.

HMAC(K, m) = SHA1((K' ⊕ opad) || SHA1((K' ⊕ ipad) || m))

Where:
- K is the secret key
- K' is the key derived from K (padded or hashed as needed)
- opad is the outer padding (0x5C repeated)
- ipad is the inner padding (0x36 repeated)
- ⊕ is XOR operation
- || is concatenation
            

Despite the added security from the HMAC construction, modern security standards recommend migrating from HMAC-SHA1 to HMAC-SHA256 or other stronger alternatives for new applications.

SHA-1 Compared to Other Hash Functions

Hash Function Output Size Security Status Performance Best Use Cases
MD5 128 bits Broken (trivial collisions) Very Fast Non-security checksums only
SHA-1 160 bits Broken (practical collisions) Fast Legacy compatibility only
SHA-256 256 bits Secure Moderate General cryptographic applications
SHA-512 512 bits Highly Secure Fast on 64-bit systems High-security applications
SHA-3 224-512 bits Highly Secure Varies Future-proof applications

Legitimate Uses of SHA-1 Today

While SHA-1 is deprecated for security-critical applications, it may still be acceptable in certain limited scenarios:

Non-Security Critical Checksums

SHA-1 can be used for basic data integrity checks where there is no adversarial threat model (i.e., where accidental corruption is the only concern).

Backward Compatibility

Some legacy systems may require SHA-1 for compatibility. In these cases, additional security measures should be implemented wherever possible.

Hash-based Data Structures

In some data structures where collision resistance is not a security requirement but performance matters, SHA-1 may still be used (although modern alternatives like BLAKE2 offer better performance and security).

SHA-1 Should Never Be Used For:

  • Digital signatures or certificates
  • Password hashing or storage
  • Securing sensitive communications
  • Any application where collision resistance is required
  • New security protocols or applications

Conclusion

SHA-1 played a significant role in internet security for many years, but its time has passed. The demonstrated collision attacks against SHA-1 make it unsuitable for any security-critical applications. Modern systems should use SHA-256, SHA-512, or SHA-3 for cryptographic purposes.

This generator tool is provided primarily for educational purposes, testing with legacy systems, and understanding the evolution of cryptographic hash functions. For any new development or security implementation, please use stronger alternatives.