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 NIST in 1995. It produces a 160-bit (20-byte) hash value, typically rendered as a 40-character hexadecimal string.
SHA-1 was widely used for decades in security protocols including SSL/TLS, PGP, SSH, S/MIME, and IPsec. It was also the hash function used in the Git version control system for identifying commits, trees, and blobs.
Security notice: SHA-1 has been deprecated for cryptographic use since 2017 when Google demonstrated a practical collision attack (SHAttered). For security-sensitive applications, use SHA-256 or SHA-512 instead.
How SHA-1 Works
SHA-1 processes input data in 512-bit blocks and maintains a 160-bit state through 80 rounds of operations:
- Message padding — The input is padded to a length that is a multiple of 512 bits, similar to MD5.
- Message schedule — Each 512-bit block is expanded into eighty 32-bit words used in the compression function.
- Compression — Five 32-bit variables go through 80 rounds using bitwise operations, addition, and rotation.
- Final hash — The five 32-bit values are concatenated to form the final 160-bit hash.
SHA-1 in Git
Git has historically used SHA-1 to generate unique identifiers for all objects in a repository. Every commit, tree, blob, and tag is identified by its SHA-1 hash. While Git is transitioning to SHA-256, SHA-1 remains the default in most installations and repositories worldwide.
Common Uses of SHA-1
- Git version control — Identifying commits and objects in Git repositories.
- File integrity checks — Verifying that files have not been corrupted during transfer or storage.
- Legacy certificate validation — Older SSL/TLS certificates used SHA-1 signatures (now deprecated).
- Data fingerprinting — Creating unique fingerprints for content identification and deduplication.
Frequently Asked Questions
Is SHA-1 secure?
SHA-1 is no longer considered secure for cryptographic purposes. Practical collision attacks have been demonstrated. However, it remains safe for non-security uses like checksums and content identification where collision resistance is not critical.
What should I use instead of SHA-1?
For cryptographic applications, use SHA-256 or SHA-512 from the SHA-2 family. For password hashing, use dedicated algorithms like bcrypt, scrypt, or Argon2.
Is the SHA-1 hash on this page computed securely?
Yes. The hash is computed on the server when you submit the form. Your input is sent securely and the result is returned immediately.