1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
From: =?utf-8?q?Christian_G=C3=B6ttsche?= <cgzones@googlemail.com>
Date: Sun, 15 Feb 2026 11:59:50 +0100
Subject: Use djb2 for string hashing
Use a well-established string hashing function instead of a custom one.
Forwarded: https://github.com/jvdmr/mod_evasive/pull/61
---
mod_evasive24.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mod_evasive24.c b/mod_evasive24.c
index f05322a..e2ad076 100644
--- a/mod_evasive24.c
+++ b/mod_evasive24.c
@@ -706,8 +706,8 @@ static size_t ntt_prime_get_next(size_t n) {
/* Find the numeric position in the hash table based on key and modulus */
static size_t ntt_hashcode(const struct ntt *ntt, const char *key) {
- size_t val = 0;
- for (; *key; ++key) val = 5 * val + *key;
+ size_t val = 5381;
+ for (; *key; ++key) val = ((val << 5) + val) + *key;
return(val % ntt->size);
}
|