SHA-256 and HMAC: The Two Functions Behind Every Provably Fair Round

How SHA-256 and HMAC-SHA256 work in provably fair games: fixed 64-character hashes, preimage resistance, the avalanche effect and why the seed is the key.

Updated November 3, 2026

Contents
  1. What does a hash function actually do?
  2. Why is a SHA-256 hash always 64 characters?
  3. Can anyone work backward from the hash to the seed?
  4. What does the avalanche effect look like with real hashes?
  5. What does HMAC add on top of SHA-256?
  6. Why do provably fair games key HMAC with the server seed?

Type anything, watch the hash

SHA-256 (64 hex characters)

d7b024fabd36c771edb0bd4c948ece99b6b42b74766f0bf59733653389aec8ac

Change one character: player-18 hashes to 00a53ef5c8d4dc05…, with no visible link to the first.

256 bits
SHA-256 output, whatever the input
64
Hex characters in every SHA-256 hash
128 bits
Collision strength of SHA-256 (NIST)
64 bytes
HMAC block size for SHA-256

Type player-17 into SHA-256 and you get d7b024fabd36c771…3389aec8ac. Change the 7 to an 8 and the output becomes 00a53ef5c8d4dc05…c033ac8901: 62 of the 64 characters are different, and 129 of the 256 underlying bits flipped. That behavior, plus the fact that nobody can run the function backward, is why provably fair games lean on SHA-256 for the commitment and on HMAC-SHA256 for the result.

The two jobs are separate. SHA-256 of the server seed is the fingerprint a game shows before you play. HMAC-SHA256, keyed with that same server seed, turns your client seed and nonce into the bytes the game reads. This page explains both, with every hash computed in code rather than typed by hand.

What does a hash function actually do?

A hash function takes an input of any length and returns an output of fixed length. The Secure Hash Standard, NIST's FIPS 180-4 from August 2015, specifies SHA-256 for messages of any length below 264 bits and describes the output as a condensed representation called a message digest. Feed it one character or a whole book and you get the same size of answer.

The standard puts the useful property plainly: any change to the message will, with a very high probability, give a different digest. That is what lets a short string stand in for a long secret. If you hold the digest and someone later hands you the secret, you can hash it and see whether the two belong together.

A hash is not encryption, which trips people up. Encryption is built to be reversed by whoever holds the key. A hash has no key and no reverse step; the input is simply gone from the output. That is exactly what a game needs for a commitment it must not be able to change, and must not be able to read back for you early.

SHA-256 was first standardized in FIPS 180-2, approved in August 2002, alongside SHA-384 and SHA-512. It is also the function the Bitcoin white paper names for its proof-of-work, which is one reason so much free tooling exists for it.

Why is a SHA-256 hash always 64 characters?

SHA-256 always returns 256 bits. Hexadecimal writes 4 bits per character, using 0–9 and a–f, so 256 bits take exactly 64 characters. Not 63, not 65.

That makes a quick sanity check possible. The empty string, zero characters long, hashes to e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855. The three letters abc give ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad. The example server seed on this site, 64 characters itself, gives f51376a5a542e19876a861e25e058cc522a304cd3edbd012bad096d8cc543de0. Every output is the same length. A published hash with any other length, or with letters past f, is not a SHA-256 hex digest, and the verifier rejects it before computing anything.

The function is also deterministic. The same input gives the same output on every machine, in every language, forever. That is the property that lets you check a game's commitment with your own tools years later.

Can anyone work backward from the hash to the seed?

Not in any practical sense. This is preimage resistance: given a digest, finding an input that produces it should take about as much work as trying every possibility. NIST's hash function guidance rates SHA-256 at 256 bits of preimage strength and 128 bits of collision strength, the second meaning it is far harder than anyone can manage to find two inputs with the same digest.

There is a catch, and it matters for games. Preimage resistance protects a secret only if the secret is hard to guess. If a server seed were the word lucky, anyone could hash lucky, compare, and know the seed. The protection comes from the hash function and a long random seed together. A 64-character random hex seed has 256 bits of randomness, which is enough.

SHA-1 is a useful warning here. In February 2017, researchers from CWI Amsterdam and Google published SHAttered, the first practical SHA-1 collision: two different PDF files with the same SHA-1 hash. Nothing comparable exists for SHA-256, but it is why nobody should accept a commitment made with SHA-1 or MD5 today.

What does the avalanche effect look like with real hashes?

The avalanche effect is the name for what happened in the opening: a tiny change in the input changes about half the output bits, with no visible pattern. Here are the computed values.

Input SHA-256 output Change
player-17 d7b024fabd36c771edb0bd4c948ece99b6b42b74766f0bf59733653389aec8ac starting point
player-18 00a53ef5c8d4dc05d1dda20de7e99fccf18605f8d304ac6e46f0a4c033ac8901 1 character in, 129 of 256 bits out
seed and nonce 8f11303cc976f994544c851b5d1114a8c58242c2870fbc1171df66271cdc2fce starting point
Seed and nonce 0856a6000a4b8efca012926aa878fe704d352ee7d201c0deab202ad8c429984f capital S only

Why does this matter to you? A site cannot nudge a seed slightly to get a slightly different, still-matching hash. Change one character of the example server seed, the final 8 to a 9, and the hash starts 22a352ff instead of f51376a5. There are no near misses.

What does HMAC add on top of SHA-256?

A key. HMAC, published as RFC 2104 in February 1997 by Hugo Krawczyk, Mihir Bellare and Ran Canetti and later standardized by NIST as FIPS 198-1 in July 2008, builds a keyed hash out of an ordinary one. Only someone who knows the key can compute the output, yet anyone who later learns the key can check it.

The construction hashes twice. The key is mixed with one fixed byte pattern for the inner hash and another for the outer hash:

HMAC(K, m) = H( (K ⊕ opad) ‖ H( (K ⊕ ipad) ‖ m ) )
ipad = byte 0x36 repeated B times, opad = byte 0x5C repeated B times
B = 64 bytes for SHA-256

HMAC-SHA256(key = a411321f…fd78, message = player-17:1:0)
= 6bf446d5eea533d95c787f63c2ac5b6943a7f7dcf4dc68f9edf3569f0c50953f

Key length has its own rule in RFC 2104. Keys longer than the block size are hashed first, and keys shorter than the output length, 32 bytes for SHA-256, are discouraged because they weaken the result. A 64-character seed used as text is 64 bytes, exactly one block, so it goes in as it is.

Why not just hash the seed and the message glued together? Partly because SHA-256 has a known property called length extension: from the hash of a secret plus a message, an attacker can compute the hash of that secret plus a longer message without knowing the secret. HMAC was designed so this does not carry over. The two approaches also simply give different numbers. SHA-256 of the seed followed by player-17:1:0 starts 8cbd4cc8, while the HMAC above starts 6bf446d5, so a verifier has to use exactly the function the game uses.

Why do provably fair games key HMAC with the server seed?

Because it puts the secret in the one place a keyed function protects it. In the reference scheme this site uses, the server seed is the key and the public values form the message:

commitment = SHA-256(server seed)                        shown before play
bytes      = HMAC-SHA256(server seed, client seed:nonce:0)
x          = b0/256 + b1/256² + b2/256³ + b3/256⁴

first four bytes 6b f4 46 d5 → x ≈ 0.4216961164 → dice 42.17

While the seed is secret, you cannot predict the next result even though you know your client seed and the nonce. Once the seed is revealed, you can recompute every bet made with it, and the commitment shows the seed was fixed before the first one. Our walkthrough of commit-reveal in provably fair games follows that sequence through a full seed rotation.

Real platforms vary the details: the order and separators in the message, whether a round index is added, how many bytes are read and how they become a game outcome. The exact scheme this site reproduces is set out in how the provably fair algorithm works, and the overview of how provably fair works shows where these two functions sit in the larger picture. Before trusting any verification, confirm the platform describes its own layout, because the same seeds under a different message give unrelated bytes.

SHA-256 and HMAC fix the inputs and make the arithmetic checkable. That is where their reach ends. They say nothing about the payout table attached to the number at the end, and a game with a large house edge can be perfectly verifiable.

FAQ

01

Can a SHA-256 hash be decrypted?

No, because it was never encrypted. A hash is a one-way fingerprint, and NIST rates SHA-256 at 256 bits of preimage strength, so there is no practical way to compute the input from the output.
02

Why is a SHA-256 hash always 64 characters?

SHA-256 always outputs 256 bits. Written in hexadecimal, each character carries 4 bits, so 256 bits take exactly 64 characters, whatever the length of the input.
03

Can two different seeds have the same SHA-256 hash?

In theory yes, since there are more possible inputs than outputs. In practice nobody has ever published a SHA-256 collision, and NIST rates its collision resistance at 128 bits.
04

What does HMAC stand for?

Hash-based Message Authentication Code, often read as keyed-hash message authentication code. It is defined in RFC 2104 and standardized by NIST in FIPS 198-1.
05

Is HMAC-SHA256 the same as SHA-256 of the seed plus the message?

No. HMAC hashes twice with the key mixed in through two fixed padding constants, which gives a different output from a plain hash of the joined strings. For the example round the two start 6bf446d5 and 8cbd4cc8.
06

Why do provably fair games use the server seed as the HMAC key?

The key is the secret part. Until the server seed is revealed nobody can compute the outcomes, and once it is revealed anyone can recompute every one of them with the public client seed and nonce.
07

Is SHA-256 safe enough for this use?

For committing to a seed, yes. The realistic weak point is a short or guessable seed, which someone could find by trying candidates, so the seed must be long and random.
08

Can I compute these hashes myself?

Yes. Any SHA-256 tool, Python's hashlib and hmac modules, or the openssl command line will reproduce the values on this page, and the verifier does it in your browser.
09

Is the hash commitment an HMAC?

Not in the reference scheme. The commitment is plain SHA-256 of the server seed; HMAC is used afterward to turn the seed, client seed and nonce into a result.