freecoding.school100% FREE · NO SIGNUP
Ledger LandISSUE #5 of 90

hashing · sha-256 · keccak · collision resistance

BlockyVSDouble-Spend Dan
Blocky saysHashing turns any data into a fixed fingerprint; change one bit and the hash changes completely.

A cryptographic hash (SHA-256, Keccak) maps any input to a fixed-size output that's deterministic, fast to compute, infeasible to reverse, and collision-resistant. The avalanche effect means a tiny change yields a totally different hash. Blockchains hash each block (including the previous block's hash), so altering old data would break every hash after it — that's the "chain".

Power-ups you unlock

Double-Spend Dan attacks — common mistakes

Boss battleUse the demo to hash a string, change one character, and watch the output change.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><input id="i" value="hello" style="background:#0c081a;color:#e6e0ff;border:1px solid #2a1d4a;padding:6px"><pre id="o"></pre>
<script>const i=document.getElementById('i'),o=document.getElementById('o');async function h(){const b=await crypto.subtle.digest('SHA-256',new TextEncoder().encode(i.value));o.textContent=[...new Uint8Array(b)].map(x=>x.toString(16).padStart(2,'0')).join('').slice(0,32)+'…';}i.oninput=h;h();</script></body></html>
▶ Open the interactive comic issue
‹ Cryptography · The FoundationPublic Key Crypto · Rsa · Ecdsa · Ed25519 ›