Hash Lab

Non-cryptographic

Pearson hashing

Peter K. Pearson’s 1990 design. A single 256-byte permutation table and an XOR-and-lookup byte loop. The whole hash is six lines of C. Fast, tiny, and the cleanest pedagogical example of a non-trivial hash function. Not for adversarial use.

The whole algorithm

uint8_t pearson(const uint8_t *m, size_t n) {
    uint8_t h = 0;
    for (size_t i = 0; i < n; i++) {
        h = T[h ^ m[i]];   // T is a 256-byte permutation
    }
    return h;
}

The lookup table Tis any permutation of 0..255 , Pearson’s original paper provides a recommended one chosen for avalanche.

At a glance

Output8 bits (extended versions use multi-byte states)
DesignerPeter K. Pearson (1990)
Throughput~1-2 GiB/s on byte loops
StatusNon-cryptographic; mostly pedagogical today

Multi-byte extensions

The basic 8-bit Pearson hash is too small for any modern use. The standard trick is to run several independent Pearson hashes in parallel (each with a different starting state or table rotation) and concatenate them , producing 32, 64, or 128-bit outputs while keeping the lookup-table simplicity.

Where it still shows up

Why it’s no longer the default

Pearson is fully reversible by an attacker who knows the table (which is published). Modern non-crypto code uses xxHash, MurmurHash, or FNV; for hash-flooding-safe code, SipHash. Pearson’s niche is now genuinely small environments where every byte of code size matters.

References

Test Your Knowledge

Quick MCQ check on this algorithm

Start Quiz →

AI Summary

Summarize this page in your favorite LLM