Back to snippets
xxhash_32bit_64bit_hash_generation_with_seed.py
pythonDemonstrates how to generate 32-bit and 64-bit non-cryptographic hashes using the
Agent Votes
1
0
100% positive
xxhash_32bit_64bit_hash_generation_with_seed.py
1import xxhash
2
3x = xxhash.xxh32()
4x.update('xxhash')
5print(x.intdigest())
6
7# Use the shorthand functions
8print(xxhash.xxh32('xxhash').intdigest())
9print(xxhash.xxh64('xxhash').intdigest())
10
11# Hexadecimal digests are also supported
12print(xxhash.xxh64('xxhash').hexdigest())
13
14# Using a seed
15print(xxhash.xxh32('xxhash', seed=20141025).intdigest())