Lion Cipher Lab

Implement SHA-256 from scratch, and verify it against the FIPS 180-4 test vectors

Why it matters

SHA-256 is everywhere: file checksums, TLS certificates, Git, code signing, blockchains, password reset tokens. Most people treat it as a magic box. This lab opens the box. You build SHA-256 yourself in about 100 lines of plain Python, following the official US standard (FIPS 180-4) section by section, and you compute its strange-looking constants from prime numbers instead of copying them. Then you prove it is right the way professionals do. You check it against NIST's published examples, and you compare it byte for byte against Python's built-in version on thousands of inputs. The most…

What you'll learn

Steps in this lab

  1. What you are building, and the words you need
  2. Set up: a terminal, Python, and a lab folder
  3. Write SHA-256, one FIPS section at a time
  4. Check the constants you computed against the FIPS tables
  5. Verify against the NIST vectors, down to round 0
  6. Differential test against hashlib: every length, then random inputs
  7. Plant a padding bug: the NIST vectors pass, the length sweep catches it
  8. Measure the avalanche effect, and watch it collapse with fewer rounds
  9. Honest negative: why your SHA-256 must never ship (speed and timing)
  10. A correct SHA-256 is still the wrong tool for passwords and for MACs
  11. Do it better: how a professional tests crypto code

Open the full interactive lab →