A Python wrapper for SpookyHash version 2
Project description
spookyhash
A Python wrapper of Bob Jenkins' SpookyHash version 2. Offers 32- 64- and 128-bit oneshot and incremental hashes.
License
Licensed under the MIT license. See the LICENSE file in the repository root for more details.
Usage
Oneshot Hashes
>>> import spookyhash
>>> spookyhash.hash32(b'hello world')
2617184861
>>> spookyhash.hash32(b'hello world', seed=0x12345678)
3380090220
>>> spookyhash.hash64(b'hello world')
14865987102431973981
>>> spookyhash.hash64(b'hello world', seed=123)
5719863273689036421
>>> spookyhash.hash128(b'hello world')
185933735475381961281710998418114941533
>>> spookyhash.hash128(b'hello world', seed1=123_000, seed2=456_000)
144121310386202441278894605216246194925
>>> # For a more comparable result to other libraries
>>> spookyhash.hash128_pair(b'hello world')
(14865987102431973981, 10079487997037711397)
>>> spookyhash.hash128_pair(b'hello world', seed1=123_000, seed2=456_000)
(12678109464562819821, 7812831891108919044)
Incremental Hashes
>>> import spookyhash
>>> sh = spookyhash.Hash32()
>>> sh.update(b'hello')
>>> sh.update(b' ')
>>> sh.update(b'world')
>>> sh.final()
2617184861
>>> spookyhash.Hash64(b'hello ', seed=123).update(b'world').final()
5719863273689036421
>>> sh = spookyhash.Hash128(seed1=123_000, seed2=456_000)
>>> sh.update(b'hello world')
>>> sh.final()
144121310386202441278894605216246194925
>>> sh.final_pair()
(12678109464562819821, 7812831891108919044)
Platform Independence
If run on a big-endian system, the code would produce different hashes, but of equal quality.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
spookyhash-2.0.0.tar.gz
(50.3 kB
view hashes)
Built Distributions
Close
Hashes for spookyhash-2.0.0-py3.9-linux-x86_64.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 210ea617d397a497e6eb2c6982cfcdc3cefced2fcc37d024fdaefe69a6634484 |
|
MD5 | 7a4e4fc80b8e597752fef4449d3782c6 |
|
BLAKE2b-256 | 2dd3f5804ea6d2636be2ba1f7b62255e509e9af12090a93da209f8f06e43f27f |
Close
Hashes for spookyhash-2.0.0-py3.8-linux-x86_64.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3587f927791fbd5a042561f55f06bdc02203d00139da4cf15bde3d30f370732 |
|
MD5 | 5aaa25fb7ea6bf16bd074e40a7c5bbe7 |
|
BLAKE2b-256 | 19430103d6c1e46708d314ed9406186348970eb7174434e380bba557689a63c8 |
Close
Hashes for spookyhash-2.0.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c271ffbe878d490109daa1c6dfb7065b9d239b08f49ae82b920843cd4e4b6c09 |
|
MD5 | bb6d77b3ff685b08c105c4f1e13c8495 |
|
BLAKE2b-256 | 5661675254bf49de05905f4a81ebf37dfc79df82a1a449f9064d4c9852c35261 |
Close
Hashes for spookyhash-2.0.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85670e6ca57d250252da04a54645022ed06e6dec2b175b407179b3f7d8888e1d |
|
MD5 | 76d5f781d5874f2cdf510eb462e61467 |
|
BLAKE2b-256 | 5840c2d9a61f3faa4ba17fa7fdc58cdb1442e655811ac8c786ae960446aed459 |