Skip to content

Instantly share code, notes, and snippets.

@fabiolimace
Created October 31, 2021 03:46
Show Gist options
  • Save fabiolimace/3169299a0bfaf4509e97c216e40f6d79 to your computer and use it in GitHub Desktop.
Save fabiolimace/3169299a0bfaf4509e97c216e40f6d79 to your computer and use it in GitHub Desktop.
A simple hash using CRC32 and Adler32 in Python
#!/usr/bin/python3
import zlib
def get_hash(bytes):
return zlib.crc32(bytes) << 32 | zlib.adler32(bytes)
string = "This is a test string"
hash = get_hash(string.encode())
print("output:", hash)
# output: 7732385261082445741
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment