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
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef HASH_H
00042 #define HASH_H
00043
00044 #include <shogun/base/SGObject.h>
00045 #include <shogun/lib/common.h>
00046
00047 namespace shogun
00048 {
00055 class CHash : public CSGObject
00056 {
00057 public:
00059 CHash() {}
00061 virtual ~CHash() {}
00062
00068 static uint32_t crc32(uint8_t *data, int32_t len);
00069
00077 static void MD5(unsigned char *x, unsigned l, unsigned char *buf);
00078
00087 static uint32_t MurmurHash2(uint8_t* data, int32_t len, uint32_t seed);
00088
00096 static uint32_t IncrementalMurmurHash2(uint8_t data, uint32_t h);
00097
00108 static uint32_t MurmurHashString(substring s, uint32_t h);
00109
00111 inline virtual const char* get_name() const { return "Hash"; }
00112
00113 protected:
00114
00115 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00116
00117 struct MD5Context {
00119 uint32_t buf[4];
00121 uint32_t bits[2];
00123 unsigned char in[64];
00124 };
00125 #endif // DOXYGEN_SHOULD_SKIP_THIS
00126
00133 static void MD5Init(struct MD5Context *context);
00134
00143 static void MD5Update(struct MD5Context *context,
00144 unsigned char const *buf, unsigned len);
00145
00153 static void MD5Final(unsigned char digest[16],
00154 struct MD5Context *context);
00163 static void MD5Transform(uint32_t buf[4], uint32_t const in[16]);
00164 };
00165 }
00166 #endif