Visualizations
223 / 500

223 · Algorithms

Hash Avalanche

Real SHA-256 woven round by round: flip one input bit and half the state catches fire.

This is the genuine SHA-256 compression function, 32-bit modular arithmetic and all, run on your text and on a copy with one message bit flipped. Each of the 65 rows of the cloth is the 256-bit working state a..h after a round, woven like a Jacquard loom: a 1 lifts the cream weft over the indigo warp, a 0 leaves the warp on top, and the narrow strip on the left is the message schedule word W[t] mixed into that round. Wherever the two runs disagree the thread burns orange. The flip stays invisible until its schedule word enters at round t, then the shift-register structure carries it into all eight words within about four rounds, and from there roughly half the bits differ, exactly what you would expect of a random function. The bars on the right count the differing bits per round and the two digests at the bottom share almost nothing.

Try it. Type to edit the message (up to 55 bytes, one block) and Backspace to delete. Click any bit of the message block, or a message word in the W strip, to choose which bit is flipped; arrow keys move the flip by a bit or a word and Enter picks a random one. Hover a row to inspect both runs' words in hex.

  • SHA-256 compression
  • 32-bit modular arithmetic
  • Avalanche effect
  • Procedural weave shading

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build an interactive visualization of the SHA-256 avalanche effect with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Implement SHA-256 yourself for a single 512-bit block (messages up to 55 bytes): pad the UTF-8 bytes with 0x80, zeros and the 64-bit bit length, build the 64-word message schedule, and run the 64 rounds. Use 32-bit arithmetic with `| 0` and `>>> 0`, and check your result against a known hash such as the one for "abc".
- Record the eight working words a..h after every round, so you have 65 rows of 256 bits.
- Run it twice: once on the message, once with a single message bit flipped.
- Draw the rows as a grid of small cells, one row per round, light for 1 and dark for 0, and paint the cells where the two runs differ in a bright warm color.
- Add a text input that recomputes both runs as you type, and let clicking a cell in a small 16 x 32 grid of the message block choose which bit is flipped.

Once that works, make it beautiful:
- Reveal the rounds one row at a time so the difference visibly spreads, starting from the round where the flipped word enters.
- Draw a bar beside each row counting the differing bits, with a line at 128 (half the state), and show both final digests with differing hex digits highlighted.
- Give the differing cells a soft glow (a blurred copy drawn with globalCompositeOperation = "lighter").

Explain the key ideas in short code comments, especially what Σ0, Σ1, Ch and Maj do. When you're done, tell me how to open it and suggest three directions I could take it next, such as shading the cells like woven threads, a magnifier with each round's words in hex, or comparing a deliberately weak hash with fewer rounds.
PreviousStellar VampireA star overflows its Roche lobe and feeds a white dwarf's disk until it ignites a nova. NextRandom Matrix SpectraEigenvalues of random matrices repel like charges, live, every frame.

Related visualizations

  • Hidden in PixelsType and image A treasure map hides in a landscape's lowest bits. Peel the bit planes to find it.
  • Huffman GardenAlgorithms Letter frequencies sprout into a Huffman tree drawn as a botanical plate.
  • Marble ComputerPhysics A wooden pegboard computer where falling marbles count, add and multiply in binary.
  • Visual CryptographyIllusions Two sheets of pure noise. Slide one over the other and a secret appears.
  • Cuckoo Hash HotelAlgorithms Three pastel hotels, three hash tables: linear probing, Robin Hood and cuckoo.
  • Compression EchoesType and image LZ77 compresses a poem while every back-reference loops back over the page in gold.
  • Sorting TapestryAlgorithms Six sorting algorithms cross-stitch a scrambled sampler back into a rainbow.
  • Automaton OrchestraEmergence Elementary cellular automata woven into cloth on a loom and played as music.
  • JPEG AnatomyAlgorithms A real JPEG codec runs live on a moving scene, every stage down to its 64 cosines.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs