Repo-Init
Loading...
Searching...
No Matches
Hasher.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <cstdint>
4
#include <cstdio>
5
6
// NOLINTBEGIN
7
13
constexpr
size_t
constHasher
(
const
char
*s) {
return
(s && *s) ? (*s + 33 *
constHasher
(s + 1)) : 5381; }
14
21
template
<
size_t
N>
constexpr
uint64_t
constSeeder
(
const
char
(&entropy)[N],
const
uint64_t iv = 0)
22
{
23
auto
value{iv};
24
for
(
size_t
i{0}; i < N; i++)
25
{
26
// Xor 1st byte of seed with input byte
27
value = (value & (unsigned(~0) << 8)) | ((value & 0xFF) ^ entropy[i]);
28
// Rotl 1 byte
29
value = value << 8 | value >> ((
sizeof
(value) * 8) - 8);
30
}
31
return
value ^ iv;
32
}
33
34
// NOLINTEND
constSeeder
constexpr uint64_t constSeeder(const char(&entropy)[N], const uint64_t iv=0)
Definition
Hasher.hpp:21
constHasher
constexpr size_t constHasher(const char *s)
Definition
Hasher.hpp:13
include
utils
Hasher.hpp
Generated on Sun Nov 10 2024 08:35:45 for Repo-Init by
1.11.0