Security · Under the Hood

How Does SHA-256 Work?

How does SHA-256 actually process data?

SHORT ANSWER

SHA-256 works by taking your input, adding 'padding' to reach a specific length, breaking it into 512-bit chunks, and running each chunk through 64 rounds of intense mathematical mixing. The final mixed state becomes your 256-bit hash.

Step 1: Padding and Blocking

First, the algorithm adds bits to your message so its length is exactly 64 bits short of a multiple of 512. Then it appends the original message length as a 64-bit integer. Finally, it chops the padded message into 512-bit blocks.

Step 2: The 64 Rounds of Compression

Each 512-bit block is fed into a compression function alongside the current 'hash state'. Over 64 rounds, the data is mixed using bitwise operations (AND, OR, XOR), rotations, and modular addition. This destroys any recognizable pattern from the original input.

Step 3: The Avalanche Effect

Because of the intense mixing in those 64 rounds, changing even a single bit of the input (like changing 'hello' to 'Hello') completely alters the final hash. This is called the avalanche effect, and it's what makes guessing the original input computationally impossible.

TRY IT LOCALLY

Try it in your browser with our SHA-256 Hash Generator. No upload, no server.

Open SHA-256 Hash Generator →

FAQ

Why does SHA-256 use 64 rounds?

The 64 rounds provide a massive security margin against cryptanalysis. Fewer rounds (like 46) have been theoretically weakened in academic papers, but the full 64 rounds remain completely secure.

Does SHA-256 use a database?

No. SHA-256 is a pure mathematical algorithm. It doesn't look up anything in a database; it just calculates the exact same math on the input every time, guaranteeing the same output.