Skip to content

Instantly share code, notes, and snippets.

@apocalyptech
Created May 4, 2024 04:22
Show Gist options
  • Save apocalyptech/272c51fbccdce8d2dc0cb73c33b5aaa5 to your computer and use it in GitHub Desktop.
Save apocalyptech/272c51fbccdce8d2dc0cb73c33b5aaa5 to your computer and use it in GitHub Desktop.
#!/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