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