Skip to content

Adding ELFHash Algorithm #6731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Oct 30, 2022
Merged
12 changes: 12 additions & 0 deletions hashes/elf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def ELFHash(data):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As there is no test file in this pull request nor any test function or class in the file hashes/elf.py, please provide doctest for the function ELFHash

Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: ELFHash

Please provide return type hint for the function: ELFHash. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: data

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As there is no test file in this pull request nor any test function or class in the file hashes/elf.py, please provide doctest for the function ELFHash

Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: ELFHash

Please provide return type hint for the function: ELFHash. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: data

"""
Implementation of ElfHash Algorithm, a variant of PJW hash function.
"""
hash = x = i = 0
for i in range(len(data)):
hash = (hash << 4) + ord(data[i])
x = hash & 0xF0000000
if x != 0:
hash ^= (x >> 24)
hash &= ~x
return hash