From da67a81c8e43496e442931ccacf5fc3fd1b4e91e Mon Sep 17 00:00:00 2001 From: Jithin Jose Date: Fri, 18 Dec 2020 10:12:54 -0800 Subject: [PATCH] Use DJB2a hash algorithm in getHostHash() --- src/common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common.h b/src/common.h index a2d7ae2..0fb5aa4 100644 --- a/src/common.h +++ b/src/common.h @@ -165,10 +165,10 @@ static void getHostName(char* hostname, int maxlen) { #include static uint64_t getHostHash(const char* string) { - // Based on DJB2, result = result * 33 + char + // Based on DJB2a, result = result * 33 ^ char uint64_t result = 5381; for (int c = 0; string[c] != '\0'; c++){ - result = ((result << 5) + result) + string[c]; + result = ((result << 5) + result) ^ string[c]; } return result; }