#include <cstdint>
#include <cstdio>
Go to the source code of this file.
|
constexpr size_t | constHasher (const char *s) |
|
template<size_t N> |
constexpr uint64_t | constSeeder (const char(&entropy)[N], const uint64_t iv=0) |
|
◆ constHasher()
size_t constHasher |
( |
const char * | s | ) |
|
|
constexpr |
Calculates the compile-time hash value of a string.
- Parameters
-
[in] | s | The input string. Must be null-terminated. |
- Returns
- The hash value of the input string.
Definition at line 13 of file Hasher.hpp.
13{
return (s && *s) ? (*s + 33 *
constHasher(s + 1)) : 5381; }
constexpr size_t constHasher(const char *s)
◆ constSeeder()
template<size_t N>
uint64_t constSeeder |
( |
const char(&) | entropy[N], |
|
|
const uint64_t | iv = 0 ) |
|
constexpr |
Generates entropy using the input string and an initial value.
- Parameters
-
[in] | entropy | The input string used for generating entropy. |
[in] | iv | The initial value for the entropy generation. |
- Returns
- The generated entropy value.
Definition at line 21 of file Hasher.hpp.
22{
23 auto value{iv};
24 for (size_t i{0}; i < N; i++)
25 {
26
27 value = (value & (unsigned(~0) << 8)) | ((value & 0xFF) ^ entropy[i]);
28
29 value = value << 8 | value >> ((sizeof(value) * 8) - 8);
30 }
31 return value ^ iv;
32}