The original algorithm produces 1 byte long hash and is (of course) not suitable for cryptography use.
But according to wikipedia, it is possible and easy to produce Pearson hash of any length, simply by increment the first byte of the message for every next byte of the hash.
Also, if the encoding array is filled with real random numbers it will guarantee very high quality of the produced hash.
So, why this hash function is not widely used in the cryptography algorithms?
Edit1:
I have made some tests of the avalanche effect of the Pearson hash with the following byte array, generated by the https://www.random.org/lists:
141, 227, 251, 2, 201, 179, 30, 63, 93, 145, 92, 46, 6, 95, 105, 1
90, 112, 60, 84, 110, 205, 0, 253, 215, 118, 244, 218, 231, 31, 192, 67
189, 23, 66, 144, 59, 115, 248, 237, 216, 82, 217, 72, 147, 143, 125, 170
152, 154, 57, 4, 44, 131, 157, 111, 209, 185, 35, 81, 41, 182, 202, 176
113, 193, 114, 254, 39, 194, 94, 190, 37, 42, 15, 195, 188, 169, 12, 7
175, 88, 245, 127, 203, 135, 181, 178, 99, 164, 76, 235, 21, 86, 160, 243
223, 126, 136, 129, 77, 239, 132, 174, 122, 233, 87, 108, 47, 146, 158, 128
97, 162, 219, 91, 229, 222, 104, 71, 150, 55, 242, 75, 151, 206, 119, 36
58, 236, 117, 43, 74, 155, 246, 116, 153, 148, 68, 159, 210, 161, 19, 64
247, 186, 83, 29, 5, 249, 177, 196, 250, 197, 167, 230, 26, 134, 124, 240
69, 149, 65, 62, 101, 38, 183, 45, 24, 166, 33, 123, 207, 107, 241, 191
208, 85, 78, 184, 32, 89, 20, 165, 27, 22, 11, 130, 98, 80, 17, 198
200, 211, 16, 100, 51, 232, 3, 96, 73, 187, 14, 53, 121, 199, 18, 103
228, 180, 156, 252, 168, 49, 8, 171, 79, 204, 10, 139, 40, 61, 220, 212
13, 221, 109, 25, 255, 120, 70, 28, 48, 213, 234, 50, 138, 9, 52, 142
225, 172, 106, 54, 214, 163, 140, 34, 238, 224, 56, 226, 102, 137, 133, 173
After changing single bit of the message the hash function changes in the different cases from 110 to 150 bits of the 256bit hash generated.
Edit2:
Thanks to the analysis of CodesInChaos it is obvious, that the multibyte hash, as described in the wikipedia has serious flaws with the non repeating bytes in the result and in revers full repeating of the hash after the 256th byte.
But it seems that this is not a flaw of the Pearson hash by itself, but a problem of the algorithm for multibyte hash combining. All this is because the value of h in the below code is cleared to fixed value for every byte of the result by the line: h = T[x[0] + j) % 256];
for (j = 0; j < 8; j++) {
unsigned char h = T[(x[0] + j) % 256];
for (i = 1; i < len; i++) {
h = T[h ^ x[i]];
}
hh[j] = h;
}
But this problem has simple solution - don't reset the value of h after the inner loop.
I tried with the following formula: h = T[((h+j)%256 ^ x[0])]
. In my test it show repeating bytes in the result, non repeating of the hash after the 256th byte and still very good avalanche effect. The code of the modified function is (C#):
byte h = 0;
for (j = 7; j >=0; j--)
{
//h = T[(x[0] + j) % 256];
h = T[((h + j)%256 ^ x[0])];
for (i = x.Length-1; i > 0; i--)
{
h = T[h ^ x[i]];
}
hh[j] = h;
}
return hh;