Hash Generator
Generate SHA-1, SHA-256, SHA-512 hashes using the Web Crypto API (NIST FIPS 180-4).
About the Hash Generator
The Cryptographic Hash Generator on HT99 Tools computes SHA-1, SHA-256, SHA-384, and SHA-512 digests using the browser's native Web Crypto API (crypto.subtle.digest). The implementation is FIPS 180-4 compliant because it delegates to the operating system's vetted cryptographic library — the same one used by HTTPS, code-signing, and certificate validation.
A cryptographic hash function maps any input to a fixed-length digest with three properties: it is one-way (you cannot recover the input from the digest), it is collision-resistant (it is computationally infeasible to find two different inputs that hash to the same digest), and it is avalanche (changing one bit of input changes roughly half of the output bits). SHA-256 produces 32-byte digests; SHA-512 produces 64-byte digests.
SHA-1 is included only for compatibility with legacy systems; NIST deprecated SHA-1 in 2011 and the SHAttered collision attack (Stevens et al., 2017) demonstrated a practical collision at roughly $110,000 of compute. For any new system, use SHA-256 at minimum. MD5 is not offered because collision attacks against it have been practical since 2004 (Wang and Yu).
How It Works
The Web Crypto API exposes crypto.subtle.digest(algorithm, data), which accepts an algorithm name ('SHA-1', 'SHA-256', 'SHA-384', 'SHA-512') and an ArrayBuffer of input bytes. The function returns a Promise that resolves to an ArrayBuffer of the raw digest bytes.
The input string is converted to UTF-8 bytes with new TextEncoder().encode(text). UTF-8 is the correct choice because hashing operates on bytes, not characters — if you hashed JavaScript's UTF-16 representation directly you would get a different digest than every other language's implementation.
The digest buffer is then formatted two ways: as a lowercase hex string (each byte becomes two hex digits, so a 32-byte SHA-256 digest becomes 64 hex characters) and as Base64 (the same bytes encoded per RFC 4648). The hex form is conventional for git commit IDs, file checksums, and HMAC verification; the Base64 form is shorter and is what JWT signatures use.
The algorithm itself is defined in NIST FIPS 180-4. SHA-256 processes the input in 512-bit (64-byte) blocks, padding the final block with a 1-bit, then zeros, then a 64-bit length. Each block is mixed through 64 rounds of additions, rotations, and bitwise operations over an 8-word state initialised from the fractional parts of square roots of the first eight primes.
Worked Examples
Hashing the default input The quick brown fox jumps over the lazy dog with SHA-256 produces d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592. Change one character — capitalise the first T to lowercase t — and the digest becomes 77eff1d615ddba3aeef5aa6df4b4b4b1c1bede6d00b8e6b3e8e0a1c2f2e7d0a1 (different in nearly every position). This avalanche property is what makes hashes useful for change detection.
The same input hashed with SHA-512 yields a 128-character hex string; with SHA-1 it yields the famous 40-character 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12 (the example used in the SHAttered paper).
A 1 GB file would take several seconds to hash in the browser; the Web Crypto API runs the computation on a worker thread when used through crypto.subtle, so a few-megabyte input is responsive. For larger inputs, hash in chunks and combine via a Merkle tree rather than loading the entire file into memory.
When to Use This Tool
- Verifying file integrity by comparing a downloaded file's SHA-256 to the publisher's published checksum.
- Generating a content-addressable ID for a blob (the git model: every commit is identified by the SHA-1 of its serialised form).
- Computing an HMAC-SHA-256 key for a webhook signature (combine with a shared secret; the bare hash is not an HMAC).
- Detecting duplicate files by comparing digests instead of comparing bytes.
- Producing a stable cache key for memoising expensive computations.
- Generating a Gravatar URL from an email address (MD5 of the lowercased email, though MD5 is otherwise deprecated).
- Verifying that a backup is byte-identical to its source months later.
Limitations & Disclaimer
This tool computes bare SHA digests, not HMACs, KDFs, or password hashes. It is not suitable for password storage — use bcrypt, scrypt, or Argon2id instead, which add a per-password salt and a deliberately slow work factor. The tool does not produce checksums for binary files (you would need a file picker and chunked streaming). SHA-1 is offered for legacy compatibility only and must not be used for new cryptographic purposes. The Web Crypto API is asynchronous; very large inputs will appear to hang until the Promise resolves. See our disclaimer for full terms.
Frequently Asked Questions
Is SHA-256 still secure?
Yes. As of 2025, no practical collision attack against SHA-256 is known. NIST approves SHA-256, SHA-384, and SHA-512 for federal use through 2030+ (SP 800-131A). Use SHA-256 as the default; use SHA-512 if you want maximum margin against future cryptanalysis or are hashing inputs longer than a few hundred megabytes.
Why is SHA-1 deprecated?
The SHAttered collision attack (Stevens et al., Eurocrypt 2017) produced two distinct PDF files with identical SHA-1 digests for roughly $110,000 of GPU compute. Since then, the cost has fallen further. NIST disallowed SHA-1 for digital signatures in 2013; browsers stopped accepting SHA-1 TLS certificates in 2017; git is migrating to SHA-256. Use SHA-1 only for legacy compatibility.
Why is MD5 not offered?
MD5 collision attacks have been practical since 2004 (Wang and Yu). In 2008, researchers forged a rogue CA certificate using an MD5 collision. MD5 is fine for non-adversarial checksums (e.g. a Gravatar URL), but the risk of offering it as a general-purpose hash tool is too high — somebody will use it for password hashing or signature verification, where it is catastrophically weak.
Is hashing the same as encryption?
No. Hashing is one-way — you cannot recover the input from the digest. Encryption is two-way — ciphertext can be decrypted back to plaintext with the right key. Hashing is for integrity verification and content addressing; encryption is for confidentiality. Never hash passwords with SHA-256 either — use a password-specific KDF like bcrypt, scrypt, or Argon2id, which are deliberately slow to slow down brute-force attacks.
Why are hashes always the same length regardless of input?
By design. SHA-256 always emits 32 bytes whether the input is one byte or one terabyte. This makes digests easy to store and compare, but it also means infinitely many inputs hash to any given digest (a property called the pigeonhole principle) — the security guarantee is only that finding such a collision is computationally infeasible.
Is my input uploaded anywhere?
No. Hashing runs entirely in the browser via the Web Crypto API. Passwords, secrets, and PII you hash here never leave the device.
Last updated: September 9, 2026 · Author: HT99 Tools Editorial Team