SHA-1 Hash Generator
Generate SHA-1 hash from any text
Input Text
SHA-1 Hash
SHA-1 hash will appear here…
What Is SHA-1 Hashing?
SHA-1 (Secure Hash Algorithm 1) is a cryptographic hash function that produces a fixed 160-bit (20-byte) digest from any input. Published by the NSA and standardized by NIST in 1995 as FIPS PUB 180-1 and later documented in RFC 3174, SHA-1 was designed as a stronger successor to SHA-0 and MD5. The algorithm processes input in 512-bit blocks through 80 rounds of bitwise operations, producing a 40-character hexadecimal fingerprint that served as the backbone of SSL/TLS, PGP, SSH, and IPsec for over a decade.
Like all cryptographic hash functions, SHA-1 is a one-way transformation: computing the hash from an input is fast, but recovering the input from the hash alone is computationally infeasible. A single-bit change in the input produces a completely different 160-bit digest — a property called the avalanche effect. SHA-1 maps an arbitrarily large input space to a fixed 160-bit output, which means collisions (two different inputs producing the same hash) must exist mathematically. The security claim of a hash function is that finding such collisions should require approximately 2^80 operations — half the output bit length.
In 2017, Google and CWI Amsterdam published the SHAttered attack, demonstrating the first practical SHA-1 collision by producing two different PDF files with the same digest. The attack required approximately 2^63.1 SHA-1 computations — well below the theoretical 2^80 bound. In 2020, Gaetan Leurent and Thomas Peyrin further reduced the cost with a chosen-prefix collision attack requiring roughly 2^63.4 operations. As a result, all major browsers, certificate authorities, and standards bodies have deprecated SHA-1 for digital signatures and TLS certificates. However, SHA-1 remains in active use for non-security purposes: Git object IDs (though Git is migrating to SHA-256), legacy HMAC constructions, and file integrity checksums where adversarial collision resistance is not required.
Why Use This SHA-1 Generator?
Generate SHA-1 hashes instantly without installing anything or writing code. Paste your text and get the 40-character hex digest in real time — useful for verifying legacy checksums, debugging Git internals, or testing hash-based workflows.
SHA-1 Use Cases
SHA-1 vs Other Hash Algorithms
SHA-1 produces a 160-bit digest — longer than MD5 (128 bits) but significantly shorter than SHA-2 family algorithms. The table below compares digest sizes, standards, and appropriate use cases for each algorithm.
| Algorithm | Digest Size | Hex Length | Standard | Best For |
|---|---|---|---|---|
| SHA-1 | 160 bits | 40 hex chars | 1995 / RFC 3174 | Deprecated — legacy git commits, old TLS |
| SHA-256 | 256 bits | 64 hex chars | 2001 / FIPS 180-4 | TLS certificates, blockchain, JWTs |
| SHA-384 | 384 bits | 96 hex chars | 2001 / FIPS 180-4 | Government systems, higher security margin |
| SHA-512 | 512 bits | 128 hex chars | 2001 / FIPS 180-4 | Digital signatures, HMAC with large keys |
| MD5 | 128 bits | 32 hex chars | 1992 / RFC 1321 | Checksums only — broken since 2004 |
| SHA-3 | 256 bits | 64 hex chars | 2015 / FIPS 202 | Post-quantum readiness, alternative to SHA-2 |
| BLAKE3 | 256 bits | 64 hex chars | 2020 | High-performance checksums, Merkle trees |
How SHA-1 Works
SHA-1 follows the Merkle-Damgard construction: the message is padded, split into 512-bit blocks, and each block is processed through 80 rounds of bitwise operations that mix the input with a message schedule derived from the block. Five 32-bit state words (H0 through H4) carry the running hash state, and the final concatenation of these words produces the 160-bit digest.
SHA-1: 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed
(160 bits = 20 bytes = 40 hex characters)
| Step | Description |
|---|---|
| Padding | Append a 1-bit, then zeros, until message length is 448 mod 512. Append the original length as a 64-bit big-endian integer. |
| Block splitting | Divide the padded message into 512-bit (64-byte) blocks. |
| Expansion | Expand each 16-word block into 80 words using a left-rotate-by-1 XOR feedback schedule. |
| Compression | Process 80 rounds per block using four nonlinear functions (Ch, Parity, Maj, Parity) across rounds 0-19, 20-39, 40-59, and 60-79. |
| Output | Concatenate the five 32-bit state words (H0-H4) into a 160-bit (20-byte) digest, rendered as 40 hexadecimal characters. |
The key difference between SHA-1 and MD5 is the number of state words (5 vs. 4), the number of rounds per block (80 vs. 64), and the use of a message schedule with left-rotate feedback. These differences give SHA-1 a larger output (160 vs. 128 bits) and originally provided a higher security margin, though both algorithms are now considered broken for collision resistance.
Code Examples
How to generate SHA-1 hashes in popular languages and environments. Unlike MD5, SHA-1 is available in the browser Web Crypto API, making it usable without external libraries in both browser and Node.js environments.
// SHA-1 is available in the Web Crypto API
async function sha1(text) {
const data = new TextEncoder().encode(text)
const hashBuffer = await crypto.subtle.digest('SHA-1', data)
const hashArray = Array.from(new Uint8Array(hashBuffer))
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
}
await sha1('hello world')
// → "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed"
// Node.js (built-in crypto module)
const crypto = require('crypto')
crypto.createHash('sha1').update('hello world').digest('hex')
// → "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed"import hashlib
# Basic SHA-1 hash
result = hashlib.sha1(b'hello world').hexdigest()
print(result) # → "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed"
# Hash a string (encode to bytes first)
text = 'hello world'
hashlib.sha1(text.encode('utf-8')).hexdigest()
# → "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed"
# Hash a file in chunks
with open('file.bin', 'rb') as f:
sha1 = hashlib.sha1()
for chunk in iter(lambda: f.read(8192), b''):
sha1.update(chunk)
print(sha1.hexdigest())package main
import (
"crypto/sha1"
"fmt"
)
func main() {
data := []byte("hello world")
hash := sha1.Sum(data)
fmt.Printf("%x\n", hash)
// → 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed
}# Using sha1sum (Linux) or shasum (macOS) echo -n "hello world" | sha1sum # → 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed - # macOS echo -n "hello world" | shasum -a 1 # → 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed - # Hash a file sha1sum package.json # → a1b2c3d4e5f6... package.json # Using openssl (cross-platform) echo -n "hello world" | openssl sha1 # → SHA1(stdin)= 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed