Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions algorithms/djb2_seed5385_upper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python
DESCRIPTION = "DJB2 variant with seed 5385 and uppercase normalization"
TYPE = 'unsigned_int'
TEST_1 = 2671650580


def hash(data):
"""Compute the API hash from byte input.
Returns a 32-bit unsigned int.
"""
if isinstance(data, str):
data = data.encode('utf-8')

h = 5385
for b in data:
c = b
if c > 96: # lowercase -> uppercase for ASCII
c -= 32
h = (h * 33 + c) & 0xFFFFFFFF
return h