Skip to content
Back to the catalog
Project hash-functionsSecurityIntermediateBeta

Build SHA-256 and HMAC from scratch

Build SHA-256 and HMAC from scratch. Implement rotations, padding and compression blocks, then sign and verify messages without a crypto library.

Build it in your language

The tester treats your program as a black box: any language works. These are just the most convenient ones for this project.

Guide language

The stage guides read in this language. Only languages this project is fully translated into show up here; the interface language does not change.

What this project is about

A cryptographic hash is a function that shows up everywhere — passwords, signatures, blockchains, file integrity — and that almost nobody has seen from the inside. Inside, it's rotations and additions, nothing more.

You'll implement SHA-256 from the padding to the compression block, check your output against the official test vectors, and use it to build HMAC and sign real tokens.

Roadmap

7 stages across 3 phases. Every stage comes with its guide and its tests: you move on when they pass.

  1. Phase 12 stages

    Preparing the message

    Padding, length in bits, and splitting into 512-bit blocks.

    1. 01SHA-256 padding
    2. 02Blocks and words
  2. Phase 23 stages

    The heart of the hash

    Message schedule, the 64 rounds, and validation against the NIST vectors.

    1. 01Message schedule
    2. 02One compression round
    3. 03Complete digest
  3. Phase 32 stages

    Putting it to use

    HMAC-SHA256, and signing and verifying tokens in constant time.

    1. 01HMAC-SHA256
    2. 02Signed tokens

Before you start

A standards-conformant SHA-256 implementation (padding, message schedule and the 64 compression rounds), validated against the NIST vectors, plus HMAC-SHA256 on top and a utility that signs and verifies tokens with constant-time comparison.

  • bittorrent
    Coming soon

    Build your own BitTorrent client

    Build a BitTorrent client from scratch. Decode bencode, contact trackers and download a real file through the peer-to-peer protocol.

    Advanced12 stages~20 hNetworking
    bencodeP2Pprotocols+1

    Go · Python · Java

  • git
    Coming soon

    Build your own Git

    Build your own Git from scratch. Store blobs, trees and commits to understand content-addressed objects and how version control works.

    Advanced12 stages~18 hTooling
    hashingzlibDAG+1

    Go · Python · Rust