Pearson hashingPearson hashing is a non-cryptographic hash function designed for fast execution on processors with 8-bit registers. Given an input consisting of any number of bytes, it produces as output a single byte that is strongly dependent on every byte of the input. Its implementation requires only a few instructions, plus a 256-byte lookup table containing a permutation of the values 0 through 255.[1] This hash function is a CBC-MAC that uses an 8-bit substitution cipher implemented via the substitution table. An 8-bit cipher has negligible cryptographic security, so the Pearson hash function is not cryptographically strong, but it is useful for implementing hash tables or as a data integrity check code, for which purposes it offers these benefits:
One of its drawbacks when compared with other hashing algorithms designed for 8-bit processors is the suggested 256 byte lookup table, which can be prohibitively large for a small microcontroller with a program memory size on the order of hundreds of bytes. A workaround to this is to use a simple permutation function instead of a table stored in program memory. However, using a too simple function, such as The algorithm can be described by the following pseudocode, which computes the hash of message C using the permutation table T: algorithm pearson hashing is h := 0 for each c in C loop h := T[ h xor c ] end loop return h The hash variable ( Example implementationsC#, 8-bitpublic class PearsonHashing
{
public static byte Hash(string input)
{
byte[] T = { /* Permutation of 0-255 */ };
byte hash = 0;
byte[] bytes = Encoding.UTF8.GetBytes(input);
foreach (byte b in bytes)
{
hash = T[hash ^ b];
}
return hash;
}
}
See alsoReferences
|
Portal di Ensiklopedia Dunia