blob: ca377c163af9becbadce6c6dd61ac0c04c51af5d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
/*
* Copyright (C) 2007-2012 Xagasoft, All rights reserved.
*
* This file is part of the libbu++ library and is released under the
* terms of the license contained in the file LICENSE.
*/
#ifndef BU_PEARSON_HASH_H
#define BU_PEARSON_HASH_H
#include "bu/cryptohash.h"
namespace Bu
{
/**
* A pearson hash is a non-cryptographically secure hashing function that
* is very light on resources, very fast, and produces a single byte
* as it's output. It is strongly dependant on every byte in the input,
* which means that it's a good choice for adding to short messages to
* ensure that the contents of the messages are unchanged.
*
* Pearson hash is named for it's inventor Peter K. Pearson who described
* it in his article "Fast hashing of variable-length text strings"
* published in 1990 by ACM. I haven't read it, because you have to pay to
* get a copy :-P
*/
class PearsonHash : public Bu::CryptoHash
{
public:
PearsonHash();
virtual ~PearsonHash();
virtual void reset();
virtual void setSalt( const Bu::String &sSalt );
virtual void addData( const void *sData, int iSize );
using Bu::CryptoHash::addData;
virtual String getResult();
virtual void writeResult( Stream &sOut );
private:
static uint8_t aSBox[256];
uint8_t iValue;
};
};
#endif
|