Different values ​​for each hash method

Can someone please tell me what I am doing wrong? I try to hash a value with murmurhash, but I get different values ​​every time:

std::string str = "some test string";
char out[32];

MurmurHash3_x86_32(str.c_str(), str.length(), 0, out);
unsigned int hash = reinterpret_cast<unsigned int>(out);
+3
source share
2 answers

It seems to me that it MurmurHash3_x86_32returns a 32-bit hash value. But you give it 32 bytes .

You could simply:

std::string str = "some test string";

unsigned int hash;
MurmurHash3_x86_32(str.c_str(), str.length(), 0, &hash);
+4
source

The variable outis of type char []or array char. This acts as a pointer to charin most contexts. Here you throw out the value of the pointer, not the contents indicated on it.

, API MurmurHash, out 32 . 32- ( , 32- ).

+9

Source: https://habr.com/ru/post/1793320/


All Articles