Created
May 4, 2024 04:22
-
-
Save apocalyptech/272c51fbccdce8d2dc0cb73c33b5aaa5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# vim: set expandtab tabstop=4 shiftwidth=4: | |
import os | |
import sys | |
def wwiser_hash(name): | |
""" | |
https://github.com/bnnm/wwiser/blob/master/wwiser/wfnv.py | |
""" | |
hash = 2166136261 #FNV offset basis | |
namebytes = name.lower().encode('latin1') | |
for namebyte in namebytes: #for i in range(len(namebytes)): | |
hash = hash * 16777619 #FNV prime | |
hash = hash ^ namebyte #FNV xor | |
hash = hash & 0xFFFFFFFF #python clamp | |
return hash | |
def main(): | |
for name in sys.argv[1:]: | |
print('{}|{}'.format(wwiser_hash(name), name)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment