SHA-256, SHA-1 and MD5 step by step

The hash of a text or bytes with the padding, the message schedule and every round of the compression in a table.

How it works

A cryptographic hash function turns a message of any length into a short fixed-size digest, so that it is infeasible to find a message for a given digest, or two messages with the same digest. SHA-256, standardized by NIST in FIPS 180-4, gives 256 bits; SHA-1 gives 160 and MD5 128, and both of those are broken (collisions can be computed), so they should no longer be used for security.

All three follow the Merkle-Damgård construction. The message is padded with a 1 bit, zeros and its length to a multiple of 512 bits, and cut into blocks. A compression function mixes each block into a running hash value, starting from fixed initial words. In SHA-256 the 16 words of a block are expanded into 64 words (the message schedule), and 64 rounds update eight working variables with additions modulo $2^{32}$, rotations, XOR and the bit functions Ch and Maj. At the end of a block the working variables are added to the hash value.

The constants are nothing-up-my-sleeve numbers: SHA-256 uses the fractional parts of the square and cube roots of the first primes, MD5 the sines of $1, 2, \ldots, 64$. This tool shows every round of the first block and the hash value after each further block. Check: SHA-256 of abc begins with ba7816bf.

Everything is calculated in your browser. Nothing you type leaves your device.