MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / djb2

Function djb2

TactilityCore/Source/crypt/Hash.cpp:5–13  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3namespace tt::crypt {
4
5uint32_t djb2(const char* str) {
6 uint32_t hash = 5381;
7 char c = (char)*str++;
8 while (c != 0) {
9 hash = ((hash << 5) + hash) + (uint32_t)c; // hash * 33 + c
10 c = (char)*str++;
11 }
12 return hash;
13}
14
15uint32_t djb2(const void* data, size_t length) {
16 uint32_t hash = 5381;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected