cipher.ink Write a message

Tools · Hashing and verification

SHA-256 visualizer and explorer

Type any text and step through the padding, the message schedule and all 64 rounds of SHA-256, then flip one input bit to see the avalanche.

1. Padding: the block that is actually hashed

Your bytes the 1 bit zeros the length in bits

2. The message schedule: 64 words from 16

3. The 64 rounds

4. The avalanche

Nothing you type here leaves your browser.

This SHA-256 explorer shows the whole calculation as it happens, from your text to the padded block, the message schedule and each of the 64 rounds, ending in the digest. Every number comes from readable code running in your browser. Nothing is uploaded, and you can change the input and watch what moves.

Walking through it

The tool starts on the three bytes abc, the example in the SHA-256 standard (FIPS 180-4). Type anything else and the whole calculation is redone.

  1. The padded block. This is the 64-byte block that actually gets hashed: your bytes, then a single 1 bit (the byte 80), then zeros, then the message length in bits as a 64-bit number at the end.
  2. The message schedule. The 16 words of the block are shaded, and 48 more follow, built from them by the algorithm.
  3. The rounds. Drag the slider through all 64. Each round shows the eight working words a to h before and after, and highlights the two that change, a and e. When you press the button, the digest at the bottom is checked against the browser's own SHA-256.
  4. The avalanche. This flips the lowest bit of your message's first byte and compares. After about six rounds roughly half of the 256 state bits differ, and so does the final digest. That's the avalanche effect, and it's why you can't change a message a little and get a similar hash.

A message over 55 bytes needs two or more blocks (55 is 64 minus the one padding byte and the eight length bytes). The Block box lets you look at each one. The second block starts from the first block's result, not from the constants.

How it works

SHA-256 is a Merkle–Damgård hash. It reads the padded message one 64-byte block at a time, keeps a state of eight 32-bit words, and uses a compression function to mix each block into that state. SHA-256, step by step works the "abc" example through every part, and what a hash function is explains what the properties mean. The code behind this page is a readable implementation in lib-sha256.js. Its 64 round constants and eight starting values aren't typed in. They're computed from the cube roots and square roots of the first primes, as the standard defines them. Its digests are tested against the standard's own examples and against Node's crypto on hundreds of random inputs.

Common questions

Is this the same SHA-256 the other hash tools use?

The hash generator uses a vendored, optimized library. This page uses our own slower, readable code that shows every step. The explorer's button checks it against the browser's built-in implementation, and the two always agree.

Why does the padding put the length at the end?

It makes the padded message unique to the message. Two different messages can never pad to the same block sequence, and the construction's security proof needs that.

Why 64 rounds?

That's enough for every input bit to reach every output bit many times over. The avalanche line shows the state is fully mixed after about six rounds, and the rest is a safety margin.

Can I use this to hash a file?

No, this tool is for looking at the steps. The file checksum tool hashes files.

Further reading

  1. FIPS 180-4: Secure Hash Standard (SHS)
  2. NIST: Example values for SHA-256 ("abc")