Skip to content

Commit

Permalink
Merge pull request #62 from MalGamy12/main
Browse files Browse the repository at this point in the history
Add DJB2 with Uppercase Conversion hash algorithm
  • Loading branch information
herrcore authored Jan 25, 2025
2 parents 38d25a8 + 137b61c commit b40ae05
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions algorithms/djb2_uppercase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python

DESCRIPTION = "A variant of the DJB2 hash algorithm that converts lowercase letters to uppercase"
TYPE = 'unsigned_int'
TEST_1 = 0x07AB31C2

def hash(data):
hash_value = 4919
for char in data:
if isinstance(char, int):
char = chr(char)
if ord('a') <= ord(char) <= ord('z'):
char = chr(ord(char) - 32)
hash_value = (hash_value * 33) + ord(char)
return hash_value & 0xFFFFFFFF

0 comments on commit b40ae05

Please # to comment.