SHA-512 Generator
Compute SHA-512 hashes. 512-bit output, 128 hex characters.
Free online SHA-256 hash generator. Convert any text to a SHA-256 hash instantly using the SubtleCrypto Web API. Output in hex and Base64. No data leaves your browser.
Algorithm
SHA-256 belongs to the SHA-2 family, published by NIST in 2001 as FIPS 180-2 and designed by the NSA. Despite arriving only six years after SHA-1 it is a substantially more conservative design, and more than two decades of concentrated cryptanalysis has not produced a practical attack against the full function.
Message preparation follows the familiar Merkle-Damgard pattern. The input is padded with a 1 bit, then zeros, then a 64-bit big endian bit length, bringing the total to a multiple of 512 bits. Each 512-bit block is then absorbed into an internal state of eight 32-bit working variables, conventionally named a through h, which start from fixed values taken from the fractional parts of the square roots of the first eight prime numbers.
Inside a block, the sixteen 32-bit message words are expanded into sixty four words by a schedule built from two small sigma functions, each a combination of right rotations and a right shift. Those sixty four words drive 64 rounds. Every round computes two mixing functions, Ch (choose) and Maj (majority), applies two larger Sigma rotation functions to the state, and adds in one message word plus one round constant. The round constants are the first 32 bits of the fractional parts of the cube roots of the first 64 primes, a nothing up my sleeve choice that makes it verifiable that no hidden structure was inserted into the table.
The compression function is Davies-Meyer style, meaning the block output is added back into the state that went in rather than replacing it. That feed forward step is what makes the function hard to invert. After the final block, the eight words are concatenated big endian to give a 256-bit digest, printed as exactly 64 hexadecimal characters.
One consequence of the Merkle-Damgard structure is worth knowing: SHA-256 is vulnerable to length extension. Given a digest of an unknown message and its length, an attacker can compute the digest of that message plus a suffix without knowing the original. This is not a flaw in the hash so much as a trap for people who use it wrongly. Never authenticate a message by hashing a secret concatenated with the data. Use HMAC instead.
SHA-256 specification at a glance. The 64 character hexadecimal output is the most widely encountered digest format in modern software.
| Output size | 256 bits |
|---|---|
| Output length | 64 hexadecimal characters |
| Block size | 512 bits |
| Rounds | 64 |
| Year published | 2001 |
| Publisher | NSA, standardized by NIST (FIPS 180-2) |
| Security status | Secure, recommended for general use |
Collision resistance is roughly 128 bits and preimage resistance roughly 256 bits, meaning a birthday attack would need about 2^128 operations. There is no plausible amount of classical computing power that reaches that number. Even Grover's algorithm on a large quantum computer only halves the preimage bound to 128 bits, which remains comfortably out of reach.
Reference digests for three short inputs. The empty string hash beginning e3b0c442 is worth memorizing, because seeing it in a database column almost always means an empty value was hashed by mistake.
All three can be reproduced in the generator above, since SHA-256 is fully deterministic across every correct implementation. Try hashing hello and then hellp. The two inputs differ in a single bit of a single byte, yet the digests have nothing in common. This is the avalanche effect, and it is the reason a hash can serve as a tamper evident fingerprint: there is no way to nudge the output in a chosen direction by nudging the input.
SHA-256 is the sensible default for almost anything that needs a cryptographic hash. The interesting question is not where it is strong, but the handful of places where a strong hash is still the wrong tool.
One thing SHA-256 does not do is hide short predictable inputs. Hashing a ten digit phone number produces a digest that anyone can reverse by hashing all ten billion possibilities, which takes minutes. If the goal is privacy rather than integrity, you need a keyed construction such as HMAC with a secret the attacker does not have, or genuine encryption.
This one surprises people, because SHA-256 is not broken in any sense. There are no collisions, no preimages, and no reason to distrust the mathematics. It is still the wrong tool for password storage, and the reason is a design goal rather than a defect.
SHA-256 was built to be fast. Hashing a large file should not take longer than reading it from disk, and modern x86 and ARM processors even include dedicated SHA extension instructions to accelerate it further. That efficiency becomes a liability the moment the input is a human chosen password. A single high end GPU can evaluate SHA-256 billions of times per second, and a rented multi GPU instance pushes that into the hundreds of billions. Against a leaked password table, an attacker is not attacking the algorithm at all, they are simply guessing, and the algorithm is helping them guess faster.
Salting is necessary and must not be skipped. A unique random salt per user, at least 16 bytes, stored in plain text next to the hash, prevents identical passwords from producing identical digests and makes precomputed rainbow tables useless. But a salt adds no work per guess. The attacker simply targets one account at a time.
What actually defends a password table is deliberate cost. Argon2id, the winner of the Password Hashing Competition and the current OWASP first choice, is memory hard: it requires a configurable amount of RAM per evaluation, which destroys the economics of GPU and ASIC parallelism because memory is the one resource you cannot cheaply multiply. scrypt shares that property. bcrypt is not memory hard but has a work factor, decades of scrutiny, and near universal library support. If organizational policy demands a FIPS approved construction, PBKDF2-HMAC-SHA256 with a very high iteration count is acceptable, and that is the one legitimate way SHA-256 belongs anywhere near a password.
The rule of thumb: tune whichever function you choose so that a single hash takes somewhere between 100 and 500 milliseconds on your production hardware. That is imperceptible during a login and ruinous for anyone running a wordlist.
HMAC-SHA256 is the workhorse of authenticated messaging on the modern web. HMAC, defined in RFC 2104, combines a hash function with a secret key by hashing twice: the key is XORed with an inner padding constant and prepended to the message for the first hash, then XORed with an outer padding constant and prepended to that result for the second. The nested structure is what makes HMAC immune to the length extension weakness of the underlying Merkle-Damgard hash.
The guarantee is stronger than a plain hash gives you. A bare digest proves only that data was not accidentally altered, because anyone can recompute it after changing the message. An HMAC proves integrity and authenticity together: only a party holding the secret key can produce a valid tag, so a matching tag means the message came from someone who knows the key and arrived unmodified.
You meet HMAC-SHA256 constantly whether you notice it or not. It is the HS256 algorithm used to sign JWTs. It is the core of AWS Signature Version 4, where a chain of HMAC operations derives a request specific signing key from your secret access key. Stripe, GitHub, Shopify, and most other webhook providers sign their payloads with it so you can verify a callback really came from them. Signed cookies and CSRF tokens in most web frameworks use it too.
Two implementation notes that matter. Always compare HMAC values with a constant time comparison function, never with a plain equality check, because an ordinary comparison leaks how many leading bytes matched and that is enough to forge a tag byte by byte. And keep HMAC keys separate from every other secret in the system. The generator above supports HMAC-SHA256 with your own key if you need to produce or verify a tag by hand.
SHA-256 rarely travels alone in a real system. The full tools directory includes SHA-512 and SHA-1 generators for comparison, a JWT decoder for inspecting HS256 signed tokens, and Base64, hex, and URL encoding tools for the formats digests usually get wrapped in.
SHA-256 is part of the SHA-2 (Secure Hash Algorithm 2) family, published by NIST in 2001. It processes input in 512-bit blocks using 64 rounds of a compression function, producing a deterministic 256-bit fingerprint of the input. Even a single character change in the input produces a completely different output, a property called the avalanche effect. This tool uses the browser's native SubtleCrypto API to compute hashes, which means no JavaScript library is loaded and no data ever leaves your device.