Hash Lab

Application

Bitcoin

Two concrete uses of hash functions in Bitcoin: the block ID (double SHA-256 of the block header) and the standard pay-to-pubkey-hash (P2PKH) address derivation. Both run in this page; nothing is sent to a server.

Block hash = SHA-256(SHA-256(header))

A Bitcoin block’s “hash” is the double SHA-256 of its 80-byte header. Bitcoin displays it in reverse byte order (little-endian on the wire, big-endian when shown). Header field is hex, exactly 160 chars.

80 bytes (expected 80)

P2PKH address = Base58Check(0x00 ∥ RIPEMD-160(SHA-256(pubkey)))

A pay-to-pubkey-hash (P2PKH) address compresses the 33-byte compressed pubkey through SHA-256, then RIPEMD-160 (160 bits is the historical Bitcoin balance between address length and collision security), prepends a network byte, appends a 4-byte SHA-256d checksum, and encodes the whole thing in Base58.

33 bytes (expected 33 for a compressed pubkey)

P2PKH address
,

The example pubkey above derives to 1PMycacnJaSqwwJqjawXBErnLsZ7RkXUAs (a canonical demo address from the Mastering Bitcoin book).