SpookyHash v2的包装
spook的Python项目详细描述
SpookyHash v2是Bob Jenkins开发的一种快速x64目标哈希。这个 python库是bob jenkin的公共域c的包装器。++ 实施(截至2012年8月)。
在python2中,尽管事实上 不需要32位整数。
位宽度特性便于保存掩蔽操作 需要较短的散列。两者的性能没有显著差异 散列大小选项,因为它们都是作为128位散列在内部计算的。
用法
>>> from spooky import hash128, hash64, hash32 >>> s = 'this is only a test...' >>> hash128(s) #128bit python int from 2 unsigned long long ints in c 94655121727368234505791352840874203973>>> hash64(s) #64bit int 13961228348271205189>>> hash32(s) #32bit int 2261883717>>> hash32(s) == hash64(s) & 0xffffffff == hash128(s) & 0xffffffff True>>> from binascii import hexlify #if you prefer hex strings to ints >>> hexlify(hash128(s).to_bytes(16, 'little')) b'459bd186363fc0c1f1da8d27d0e93547'