Hash generator · Guide
SHA256 Hash Algorithm Explained: Inside the SHA-2 Digest
SHA-256 is the workhorse of modern integrity checking: package checksums, TLS certificate fingerprints, content addressing, blockchain. Its internals are not complicated, and knowing them explains why it has resisted twenty years of analysis.
Padding and blocks
The message is padded with a single 1 bit, then zeros, until it is 64 bits short of a multiple of 512. Those final 64 bits carry the original length in bits, so length is part of what gets hashed.
The padded message is then processed one 512-bit block at a time. Nothing is held in memory beyond the current block and the running state, which is why you can hash a terabyte file with a fixed-size buffer.
Eight words of state, 64 rounds
SHA-256 keeps 256 bits of state as eight 32-bit words, initialised from the fractional parts of the square roots of the first eight primes. Each block runs 64 rounds, each mixing in one word of the message schedule and one of 64 constants derived from cube roots of primes.
The message schedule is the part that matters for security: the sixteen words of the block are expanded into 64 words, each new word combining earlier ones through rotations and shifts. This spreads every input bit across the whole schedule long before the rounds finish.
A worked example
The classic reference values, useful for checking any implementation:
"" -> e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
"abc" -> ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
"abd" -> a52d159f262b2c6ddb724a61840befc36eb30c88877a4030b65cbe86298449c9"abc" and "abd" differ by one bit of input and share no visible structure in the output. That avalanche is what makes the digest useless for inferring anything about the original.
Why it has held up
MD5 uses four rounds over 128 bits of state; SHA-1 uses 80 rounds over 160. SHA-256 uses 64 rounds over 256 bits with a far more aggressive message schedule, and no collision attack better than brute force has been found.
Brute force means roughly 2^128 operations by the birthday bound — beyond any conceivable hardware. The known caveat is not collisions but length extension: never build authentication by hashing a secret concatenated with a message; use HMAC-SHA256 instead.
Frequently asked questions
How many rounds does SHA-256 use?
64 rounds per 512-bit block, operating on eight 32-bit state words.
Is SHA-256 the same as SHA-2?
SHA-256 is one member of the SHA-2 family, along with SHA-224, SHA-384 and SHA-512.
Has SHA-256 ever been broken?
No practical collision or preimage attack exists. The only structural caveat is length extension, which HMAC avoids.
Ready to try it?
Open the free browser-based Hash generator and apply what you just read — no sign-up, runs locally.
Open the Hash generator tool