cipher.ink Write a message

Tools · Hashing and verification

SHA-1 hash generator

Get the SHA-1 of text or a file in your browser, with the SHAttered story, known values, and what to use instead.

Or drop a file here, or click to choose one. Files of any size work.

Nothing you type or drop here leaves your browser. Files are read in 4 MB pieces by a background worker.

This SHA1 hash generator computes the SHA-1 digest of text or a file in your browser, with nothing uploaded. The digest is 160 bits, shown as 40 hexadecimal characters. Know what you're getting before you rely on it, because SHA-1 is broken for collisions. Two different files with the same SHA-1 have been built, so don't use it for signatures or to prove a file is genuine. As a checksum against accidents it still works.

Where it came from

NIST published SHA-1 in 1995 as a revision of the 1993 SHA, now called SHA-0, and the US National Security Agency designed it. It works on 64-byte blocks with 80 rounds and a state of five 32-bit words. For twenty years it was the internet's default hash, used in TLS certificates, in PGP, in software signing and in Git.

How it was broken

Cryptographers found theoretical weaknesses from 2005 on and warned for years that it should be retired. The practical proof came on 23 February 2017, when Marc Stevens, Pierre Karpman and colleagues at CWI Amsterdam and Google announced SHAttered, two different PDF files with the same SHA-1. It took about nine quintillion SHA-1 computations, roughly 6,500 years of CPU time and 110 years of GPU time spread across many machines. That's thousands of times faster than brute force, and it was still a big effort.

In January 2020 Gaëtan Leurent and Thomas Peyrin showed something cheaper and more dangerous, a chosen-prefix collision, where the attacker picks the beginning of both messages. They put the cost at about $45,000. NIST retired SHA-1 on 15 December 2022 and set the end of 2030 as the deadline for finishing the phase-out. The background is in what a hash function is.

Known values

InputSHA-1
the empty inputda39a3ee5e6b4b0d3255bfef95601890afd80709
abca9993e364706816aba3e25717850c26c9cd0d89d
helloaaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
hello and a newlinef572d396fae9206628714fb2ce00f72e94f2258f
The quick brown fox jumps over the lazy dog2fd4e1c67a2d28fced849ee1bb76e7391b93eb12

Where you'll still run into it

  • Git. Git names every commit, file and tree by a SHA-1. After SHAttered it added detection for the known collision patterns, and newer versions can create repositories that use SHA-256 instead. Using SHA-1 to name objects in your own repository is a different risk from using it to authenticate strangers' files.
  • TOTP and HOTP codes. The authenticator-app codes of RFC 6238 default to HMAC-SHA-1. That's much safer than plain SHA-1, because HMAC doesn't depend on collision resistance (HMAC explained), though new designs pick SHA-256 anyway.
  • Old checksum files and legacy protocols that call for a 40-character hash.

What to use instead

For anything new, take SHA-256 (SHA-256 hash generator) or SHA-512 (SHA-512 hash generator). The SHA-3 family (SHA-3 hash generator) has a completely different design, which is handy insurance if someone ever finds a flaw in the SHA-2 structure.

Compute it from the command line

SystemCommand
Linuxsha1sum file
macOSshasum file (SHA-1 is its default)
Windows PowerShellGet-FileHash file -Algorithm SHA1
Anywhere with OpenSSLopenssl dgst -sha1 file

To check a file against a published SHA-1 sum, use the file checksum tool.

Common questions

Is SHA-1 still secure?

Not against collisions. It was broken in practice in 2017, and a cheaper attack followed in 2020. It's still fine as a checksum against accidental damage.

Is SHA-1 reversible?

No, it's one-way like every hash function. But short inputs can be guessed, so a bare SHA-1 of a password protects very little.

Why do some sites still show a SHA-1 fingerprint?

Usually for identification where nobody's attacking, like a certificate fingerprint a person compares by eye, or for old software that expects one. A modern certificate is signed with SHA-256 or better.

Further reading

  1. Stevens et al.: The first collision for full SHA-1 (2017)
  2. Leurent and Peyrin: SHA-1 is a Shambles (2020)
  3. NIST: NIST Retires SHA-1 Cryptographic Algorithm (2022)
  4. RFC 6238: TOTP: Time-Based One-Time Password Algorithm