Skip to content

Commit 7666acc

Browse files
committed
Update elf.py
1 parent 38bd19f commit 7666acc

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

hashes/elf.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
def ELFHash(data):
1+
def elf_hash(data):
22
"""
33
Implementation of ElfHash Algorithm, a variant of PJW hash function.
4+
5+
Returns:
6+
[int] -- [32 bit binary int]
7+
>>> elf_hash('lorem ipsum')
8+
'253956621'
49
"""
510
hash = x = i = 0
611
for i in range(len(data)):
@@ -9,4 +14,9 @@ def ELFHash(data):
914
if x != 0:
1015
hash ^= (x >> 24)
1116
hash &= ~x
12-
return hash
17+
return hash
18+
19+
if __name__ == "__main__":
20+
import doctest
21+
22+
doctest.testmod()

0 commit comments

Comments
 (0)