Reading — step 1 of 5
Read
~1 min readThe Compression Function
Message Schedule
Each 512-bit (64-byte) input block is split into 16 big-endian 32-bit words W[0..15]. SHA-256 EXTENDS this to 64 words W[0..63] via:
For i = 16 to 63:
W[i] = σ1(W[i-2]) + W[i-7] + σ0(W[i-15]) + W[i-16]
(mod 2^32)
Why extend? The 64-round compression function consumes one W word per round. Mixing each later word from earlier ones gives diffusion.
Implementation:
python
That & 0xFFFFFFFF is critical — Python ints are arbitrary precision; without it your math drifts above 32 bits and corrupts later rounds.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…