aboutsummaryrefslogtreecommitdiff
path: root/src/pearsonhash.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-01-21 06:43:34 +0000
committerMike Buland <eichlan@xagasoft.com>2011-01-21 06:43:34 +0000
commit32cf9195e7c01e2f3d2ffbce06d143e67fa5a54d (patch)
treecfcac150ce2771d17a8727bfc8633b54680c1452 /src/pearsonhash.h
parent8c3f900fc99d77e478766a6b0fa34c23253cc79e (diff)
downloadlibbu++-32cf9195e7c01e2f3d2ffbce06d143e67fa5a54d.tar.gz
libbu++-32cf9195e7c01e2f3d2ffbce06d143e67fa5a54d.tar.bz2
libbu++-32cf9195e7c01e2f3d2ffbce06d143e67fa5a54d.tar.xz
libbu++-32cf9195e7c01e2f3d2ffbce06d143e67fa5a54d.zip
PearsonHash has been added to libbu++, I...have no way of really verifying that
our results are right, but I can at least write a unit test and make sure that minor changes in the inputs create different results in the output.
Diffstat (limited to '')
-rw-r--r--src/pearsonhash.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/pearsonhash.h b/src/pearsonhash.h
new file mode 100644
index 0000000..af8dfc3
--- /dev/null
+++ b/src/pearsonhash.h
@@ -0,0 +1,41 @@
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 class PearsonHash : public Bu::CryptoHash
23 {
24 public:
25 PearsonHash();
26 virtual ~PearsonHash();
27
28 virtual void reset();
29 virtual void setSalt( const Bu::String &sSalt );
30 virtual void addData( const void *sData, int iSize );
31 using Bu::CryptoHash::addData;
32 virtual String getResult();
33 virtual void writeResult( Stream &sOut );
34
35 private:
36 static uint8_t aSBox[256];
37 uint8_t iValue;
38 };
39};
40
41#endif