SHA-1 Hash Generator

Generate SHA-1 or HMAC-SHA1 output with configurable input and output encoding.

Tool

Generate SHA-1 Hash

Use the SHA-1 form in the right sidebar to choose input encoding, output encoding, and optional HMAC key, then press Generate to show the result.

Input text

Output hash

This SHA-1 tool is for educational reference, testing, and quick browser experiments. Do not use it with sensitive, confidential, or production data.

Overview

What this tool does

This browser-based SHA-1 tool generates a plain SHA-1 digest or HMAC-SHA1 output from UTF-8 text, HEX bytes, or Base64 data. It is designed for learning, quick verification, compatibility checks, and browser-based integrity testing.

A practical starting point is UTF-8 input, HEX output, and no HMAC key, then compare the same value again with HMAC enabled.

How To

How to use this tool

  1. 1

    Enter input text

    Type or paste the text, encoded value, or sample data you want to hash in the input area.

  2. 2

    Select the input encoding

    Choose UTF-8, HEX, or Base64 so the tool reads the source value in the correct format.

  3. 3

    Choose output settings

    Select HEX or Base64 for the generated digest. HEX output can be normalized with the upper-case or lower-case buttons.

  4. 4

    Optionally add an HMAC key

    Enter a UTF-8 HMAC key if you want to compute HMAC-SHA1 instead of a plain SHA-1 hash.

  5. 5

    Generate the hash

    Press Generate to compute the result.

  6. 6

    Review and normalize the result

    Check the output and selected settings, then use upper-case or lower-case conversion when the output format is HEX.

Guide

Detailed guide to SHA-1 hashing

Thumbnail image for the hash sha1.

Understanding SHA-1 hashing

SHA-1 (Secure Hash Algorithm 1) is a cryptographic hash function designed by the United States National Security Agency (NSA) and published by the National Institute of Standards and Technology (NIST) as a U.S. Federal Information Processing Standard (FIPS PUB 180-4). It produces a fixed 160-bit (20-byte) hash value, typically rendered as a 40-character hexadecimal string. SHA-1 was developed as a stronger alternative to earlier designs such as MD4 and MD5, while keeping performance practical for software implementations across a wide range of computing platforms.

The fundamental purpose of SHA-1, like all cryptographic hash functions, is to map input data of arbitrary size to a fixed-size output (the digest) in a way that is deterministic, quick to compute, preimage-resistant, and collision-resistant. According to the original RFC 3174 specification, the algorithm processes data in 512-bit blocks through 80 rounds of compression, making it computationally infeasible to reverse the process or find two distinct inputs that produce the same output under ideal conditions.

Hash function mechanism

The internal operation of SHA-1 follows the Merkle-Damgård construction, a widely studied design paradigm that underpins many classical hash functions including MD5, SHA-1, and SHA-2. The algorithm consists of several well-defined stages that transform input data into a fixed-length digest through iterative compression.

  • Message padding: SHA-1 first pads the input message to ensure its bit length is congruent to 448 modulo 512. Padding always appends a single '1' bit, followed by enough '0' bits, then a 64-bit representation of the original message length. This padding rule is critical for security and is specified in detail in FIPS PUB 180-4.
  • Block processing: The padded message is divided into consecutive 512-bit (64-byte) blocks. Each block undergoes 80 rounds of compression using a set of logical functions (f0 through f79) that combine bitwise operations including AND, OR, XOR, and NOT, along with circular left shifts.
  • Message schedule: Each 512-bit block is expanded from 16 32-bit words into an 80-word schedule (W0 through W79). Words W16 through W79 are derived from earlier words using XOR operations and left rotations, a process that ensures each output bit depends on many input bits (the avalanche effect).
  • State variables: SHA-1 maintains five 32-bit working variables (A, B, C, D, E) initialized to the fixed hexadecimal constants 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, and 0xC3D2E1F0. These initial values are defined by the SHA-1 specification and should not be confused with the square-root-derived constants used in SHA-2.
  • Final digest: After all blocks are processed, the five state variables are concatenated to produce the 160-bit (20-byte) hash value. This digest appears as a 40-character hexadecimal string when HEX output is selected, or as a 28-character padded Base64-encoded value when Base64 output is selected.

SHA-1 algorithm parameters

Parameter Value Description
Digest size 160 bits (20 bytes) Fixed output length regardless of input size
Block size 512 bits (64 bytes) Data is processed in 512-bit chunks
Word size 32 bits Internal operations use 32-bit words
Number of rounds 80 Each block undergoes 80 compression rounds
Rounds per stage 20 Four stages of 20 rounds each with distinct logical functions
Maximum message size 2^64 - 1 bits Theoretical limit per the original specification
State variables 5 (A, B, C, D, E) Five 32-bit registers hold the intermediate hash state
Construction type Merkle-Damgård Iterative compression function design
Published standard FIPS PUB 180-4 NIST Federal Information Processing Standard

SHA-1 vs other hash functions

Understanding how SHA-1 compares to other hash functions helps developers and security professionals make informed decisions about which algorithm to use for a given task. The table below provides a side-by-side comparison of SHA-1 with related hash functions, based on specifications from NIST hash function standards and the cryptographic research community.

Hash function Digest size Block size Rounds Security level (bits) Collision resistance Year introduced
MD5 128 bits 512 bits 64 < 18 (broken) Broken 1992
SHA-1 160 bits 512 bits 80 < 63 (deprecated) Weakened 1995
SHA-256 256 bits 512 bits 64 128 Secure 2001
SHA-512 512 bits 1024 bits 80 256 Secure 2001
SHA-3 (256) 256 bits 1600 bits 24 (Keccak-f) 128 Secure 2015
RIPEMD-160 160 bits 512 bits 80 80 Weakened 1996

As the comparison table shows, SHA-256 and SHA-3 offer significantly stronger security margins than SHA-1. The practical collision attack demonstrated by Google and CWI Amsterdam in 2017 (SHAttered) showed that SHA-1 collisions are no longer only theoretical. For comparison, SHA-256 remains secure against known collision attacks with an estimated birthday-bound cost of about 2^128 operations.

HMAC-SHA1

Hash-Based Message Authentication Code (HMAC) is a specific construction for creating a message authentication code (MAC) using a cryptographic hash function combined with a secret key. The HMAC-SHA1 variant applies the HMAC construction using SHA-1 as the underlying hash function. The HMAC mechanism is formally defined in RFC 2104 and remains widely deployed in legacy network protocols and API authentication schemes.

  • Construction: HMAC-SHA1 computes the digest as HMAC(K, m) = SHA1((K' xor opad) || SHA1((K' xor ipad) || m)), where K' is the key padded to the block size, opad is the outer padding (0x5c repeated), and ipad is the inner padding (0x36 repeated).
  • Keyed authentication: Unlike plain SHA-1, HMAC-SHA1 provides message authenticity verification. Only parties who share the secret key can generate or verify a valid HMAC tag.
  • Length extension resistance: The HMAC construction inherently protects against length extension attacks, a known vulnerability of plain Merkle-Damgård hash functions including SHA-1.
  • Key sensitivity: Any change in the HMAC key, even a single bit, produces a completely different output. Enter a strong UTF-8 key when you want to test HMAC-SHA1 behavior with this tool.
  • Legacy use: HMAC-SHA1 remains supported in many older protocols including TLS 1.0/1.1, IPsec, and SSH-1. However, HMAC-SHA256 is strongly recommended for all new protocol designs.

Security considerations

SHA-1 is historically important, but its security weaknesses are well-documented and widely acknowledged by the cryptographic community. The NIST Special Publication 800-131A explicitly deprecates SHA-1 for digital signature generation and verification in federal applications. Understanding these limitations is essential for anyone working with cryptographic systems.

  • Collision attacks are practical: The SHAttered attack (2017) demonstrated a real SHA-1 collision between two different PDF files. This makes SHA-1 unsuitable for digital signatures, certificates, or any application where collision resistance is critical.
  • Preimage resistance remains higher: While collision attacks are practical, preimage attacks (finding an input that produces a given output) remain computationally infeasible at approximately 2^160 operations. However, modern systems should not rely on this distinction and should migrate to stronger algorithms.
  • Length extension vulnerability: Because SHA-1 uses the Merkle-Damgård construction, it is susceptible to length extension attacks when used in plain hash mode. An attacker who knows H(M) can compute H(M || padding || extension) without knowing M. HMAC-SHA1 mitigates this concern.
  • Speed is a liability for passwords: SHA-1 is designed for speed, processing approximately 200-300 MB/s per core on modern hardware. This makes it trivially fast for brute-force password cracking. Dedicated password hashing functions like Argon2, bcrypt, or PBKDF2 add deliberate cost factors (memory hardness, iteration count) that make attacks exponentially more expensive.
  • Browser environment limitations: This tool runs entirely in the client-side browser using JavaScript. While this provides privacy benefits (no data is sent to a server), JavaScript-based cryptography has inherent limitations including potential side-channel vulnerabilities and dependence on the browser's runtime environment.

Applications of SHA-1

Despite its deprecated status for security-critical applications, SHA-1 continues to appear in several specific use cases where its properties remain useful or where legacy compatibility is required. The table below summarizes common applications and their current suitability.

Application Current status Recommended alternative
File integrity checksums (non-security) Acceptable for casual use SHA-256 for stronger assurance
Git object identifiers Still in widespread use SHA-256 transition in progress (Git 2.x+)
Digital signatures / certificates Deprecated, not recommended SHA-256 or SHA-3 with RSA/ECDSA
SSL/TLS certificate signatures Rejected by modern browsers SHA-256 (SHA-2 family)
Legacy API authentication (HMAC-SHA1) Still supported by some providers HMAC-SHA256
Password storage Never recommended Argon2, bcrypt, PBKDF2, scrypt
Educational study of hash functions Highly suitable Also study SHA-256 and SHA-3 for contrast
Deduplication (non-security) Sometimes acceptable SHA-256 for collision safety margin

History of SHA-1

The development of SHA-1 traces a critical chapter in the history of cryptographic hash functions. Designed by the NSA and published by NIST, SHA-1 was intended to correct a weakness found in its predecessor SHA-0. Its journey from widespread adoption to deprecation illustrates the evolving understanding of cryptographic security and the importance of conservative security margins in algorithm design.

  • 1993: The original Secure Hash Algorithm (SHA-0, FIPS PUB 180) is published by NIST. A subtle flaw in the message schedule is later discovered by the NSA but not publicly disclosed at the time.
  • 1995: SHA-1 (FIPS PUB 180-1) replaces SHA-0 with a single bitwise rotation change in the message schedule, correcting the undisclosed weakness. The digest remains 160 bits.
  • 2005: Academic researchers including Xiaoyun Wang, Yiqun Lisa Yin, and Hongbo Yu publish the first theoretical collision attack on SHA-1, reducing the complexity from 2^80 to approximately 2^69 operations.
  • 2011: NIST formally deprecates SHA-1 in SP 800-131A for federal digital signature applications, recommending migration to SHA-2 (SHA-256/SHA-512).
  • 2017: Google and CWI Amsterdam publicly demonstrate the first practical SHA-1 collision (SHAttered attack). Two different PDF files with distinct content produce identical SHA-1 hashes. The attack cost approximately 110 GPU-years of computation.
  • 2017 onward: Major web browsers including Chrome, Firefox, and Safari moved away from SHA-1-based TLS certificates. The industry-wide migration to SHA-256 and SHA-3 continues across security-sensitive domains.

Advanced configuration tips

  • Use UTF-8 when you are hashing plain text directly. This is the most common use case and works for all standard text formats including English, Korean, Japanese, and other Unicode character sets.
  • Use HEX when your source is already represented as hexadecimal bytes. This is useful when verifying checksums or hashing binary data that has been hex-encoded.
  • Use Base64 when your source value is already Base64-encoded binary data. The tool validates Base64 padding and character set before processing.
  • If the HEX input length is odd, the page prepends a leading zero before parsing, matching the original logic from the underlying CryptoJS library.
  • Cross-check important outputs with a trusted local library or command line tool such as OpenSSL (echo -n "message" | openssl sha1) or the built-in sha1sum utility on Linux and macOS.
  • Test the same message with and without HMAC to see the difference between unkeyed and keyed hashing. A single character change in the HMAC key produces a completely unrelated output.

Limitations and cautions

  • Client-side processing: Everything runs in the browser using JavaScript. No data is transmitted to any server, but the browser environment imposes performance and security constraints compared to native cryptographic libraries.
  • Not for passwords: SHA-1 is a fast general-purpose hash function, not a password hashing algorithm. It lacks the deliberate cost factors (salt, iteration count, memory hardness) that are essential for secure password storage.
  • Legacy strength level: NIST and the broader cryptographic community have deprecated SHA-1 for security-sensitive applications. SHA-256 or SHA-3 should be used for all new system designs.
  • Encoding sensitivity: Wrong input encoding will produce parsing errors or unexpected output. Always verify that the encoding selection matches the actual format of your input data.
  • Browser dependency: The page assumes a modern browser with JavaScript enabled and the CryptoJS library loaded. The tool will not function without JavaScript, and older browsers may have incomplete CryptoJS support.

Final tips

  1. Start with UTF-8 input and HEX output for the easiest testing flow. This combination works for most text-based use cases and produces output that is easy to compare across tools.
  2. Use HMAC only when you intentionally want keyed hashing behavior. Leaving the HMAC key empty generates a plain SHA-1 digest, which is appropriate for integrity checks and educational use.
  3. Validate important digests against another trusted implementation such as OpenSSL, Python's hashlib, or the command-line sha1sum tool to ensure correctness.
  4. Use SHA-1 mainly for education, compatibility work, and light integrity checks. For production security systems, always prefer SHA-256, SHA-3, or dedicated password hashing functions.
  5. Choose SHA-256, SHA-3, or dedicated password hashing functions for modern security-sensitive tasks. The additional computational cost is negligible compared to the security benefits.

Results are for educational and testing purposes only. Actual outputs may vary based on input accuracy, encoding choices, and whether HMAC mode is enabled. Always verify critical hash values using multiple independent implementations before relying on them for any operational purpose.

FAQ

Frequently asked questions

Can I hash HEX input with this page?

Yes. Select HEX as the input encoding. The tool validates the characters and pads an odd-length HEX value with a leading zero before parsing.

What happens if I enter an HMAC key?

When you enter an HMAC key, the page generates HMAC-SHA1 instead of a plain SHA-1 hash.

Can I use upper case or lower case conversion for Base64 output?

No. The case conversion buttons are intended for HEX output and are disabled when Base64 output is selected.

Is this page suitable for password hashing or modern high-security systems?

No. This page is mainly for educational and testing purposes. For password storage use Argon2, bcrypt, or PBKDF2, and for modern secure digests prefer SHA-256 or SHA-3.