Rumba C++ SDK
Hash24.h
Go to the documentation of this file.
1 /*
2 
3  *
4  ***
5  *****
6  ********************* Mercenaries Engineering SARL
7  ***************** Copyright (C) 2018
8  *************
9  ********* http://www.mercenaries-engineering.com
10  ***********
11  **** ****
12  ** **
13 
14 */
15 #pragma once
16 
17  namespace maquina
18  {
19 
20 // This is the 32 bits Jenkins hash masked to 24 bits
21 inline int hash_24(const uint8_t *key, size_t length)
22 {
23  uint32_t hash = 0;
24  size_t i;
25  for (i = 0; i < length; ++i) {
26  hash += key[i];
27  hash += hash << 10;
28  hash ^= hash >> 6;
29  }
30  hash += (hash << 3);
31  hash ^= (hash >> 11);
32  hash += (hash << 15);
33  return int(hash & 0xffffff);
34 }
35 
36 inline int hash_24(const std::string& str)
37 {
38  return str.empty()
39  ? 0
40  : hash_24( reinterpret_cast<const uint8_t*>( str.data() ), str.size() );
41 }
42 
43  }
This version of the SDK is unstable, i-e, it may change with no warning.
Definition: AddCurveAction.h:20
int hash_24(const uint8_t *key, size_t length)
Definition: Hash24.h:21