Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef HASH_H
00033 #define HASH_H
00034
00035 #include <shogun/base/SGObject.h>
00036 #include <shogun/lib/common.h>
00037 #include <shogun/lib/external/PMurHash.h>
00038
00039 namespace shogun
00040 {
00047 class CHash : public CSGObject
00048 {
00049 public:
00051 CHash() {}
00053 virtual ~CHash() {}
00054
00060 static uint32_t crc32(uint8_t *data, int32_t len);
00061
00069 static void MD5(unsigned char *x, unsigned l, unsigned char *buf);
00070
00080 static uint32_t MurmurHash3(uint8_t* data, int32_t len, uint32_t seed);
00081
00093 static void IncrementalMurmurHash3(uint32_t *hash, uint32_t *carry,
00094 uint8_t* data, int32_t len);
00095
00106 static uint32_t FinalizeIncrementalMurmurHash3(uint32_t h,
00107 uint32_t carry, uint32_t total_length);
00108
00119 static uint32_t MurmurHashString(substring s, uint32_t h);
00120
00122 virtual const char* get_name() const { return "Hash"; }
00123
00124 protected:
00125
00126 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00127
00128 struct MD5Context {
00130 uint32_t buf[4];
00132 uint32_t bits[2];
00133 union
00134 {
00136 unsigned char in[64];
00138 uint32_t uin[16];
00139 };
00140 };
00141 #endif // DOXYGEN_SHOULD_SKIP_THIS
00142
00149 static void MD5Init(struct MD5Context *context);
00150
00159 static void MD5Update(struct MD5Context *context,
00160 unsigned char const *buf, unsigned len);
00161
00169 static void MD5Final(unsigned char digest[16],
00170 struct MD5Context *context);
00179 static void MD5Transform(uint32_t buf[4], uint32_t const in[16]);
00180 };
00181 }
00182 #endif