From 469bbcf0701e1eb8a6670c23145b0da87357e178 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sun, 25 Mar 2012 20:00:08 +0000 Subject: Code is all reorganized. We're about ready to release. I should write up a little explenation of the arrangement. --- src/stable/pearsonhash.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/stable/pearsonhash.h (limited to 'src/stable/pearsonhash.h') 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 @@ +/* + * Copyright (C) 2007-2011 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 -- cgit v1.2.3