-
-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Adding ELFHash Algorithm #6731
Changes from 1 commit
38bd19f
fbac99b
7666acc
c26969a
71b5e8e
1f03436
0cc859c
09a6e1c
636de59
efc745c
3dcdad1
62eefeb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
def ELFHash(data): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Variable and function names should follow the Please provide return type hint for the function: Please provide type hint for the parameter: |
||
""" | ||
Implementation of ElfHash Algorithm, a variant of PJW hash function. | ||
""" | ||
hash = x = i = 0 | ||
micaelalex marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for i in range(len(data)): | ||
hash = (hash << 4) + ord(data[i]) | ||
micaelalex marked this conversation as resolved.
Show resolved
Hide resolved
|
||
x = hash & 0xF0000000 | ||
if x != 0: | ||
hash ^= (x >> 24) | ||
hash &= ~x | ||
return hash |
There was a problem hiding this comment.
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 functionELFHash
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