Skip to content

Commit 38bd19f

Browse files
committed
Adding ELFHash Algorithm
Adding a new Hash Algorithm.
1 parent 8cce0d4 commit 38bd19f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

hashes/elf.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def ELFHash(data):
2+
"""
3+
Implementation of ElfHash Algorithm, a variant of PJW hash function.
4+
"""
5+
hash = x = i = 0
6+
for i in range(len(data)):
7+
hash = (hash << 4) + ord(data[i])
8+
x = hash & 0xF0000000
9+
if x != 0:
10+
hash ^= (x >> 24)
11+
hash &= ~x
12+
return hash

0 commit comments

Comments
 (0)