Skip to main content

Python bindings for MetroHash, a fast non-cryptographic hash algorithm

Project description

A Python wrapper around MetroHash

https://travis-ci.org/escherba/python-metrohash.svg

Installation

To get started, clone this repo and run make env or, alternatively, install it into your environment of choice (below). Note that you will need to have Cython installed before you install this package.

pip install -U cython
pip install metrohash

Example Usage

This package provides Python interfaces to 64- and 128-bit implementations of MetroHash algorithm. For stateless hashing, it exports metrohash64 and metrohash128 functions. Both take a value to be hashed (either string or unicode) and an optional seed parameter:

>>> import metrohash
...
>>> metrohash.metrohash64("abc", seed=0)
17099979927131455419L
>>> metrohash.metrohash128("abc")
182995299641628952910564950850867298725L

For incremental hashing, use CMetroHash64 and CMetroHash128 classes. Incremental hashing is associative and guarantees that any combination of input slices will result in the same final hash value. This is useful for processing large inputs and stream data. Example with two slices:

>>> mh = metrohash.CMetroHash64()
>>> mh.update("Nobody inspects")
>>> mh.update(" the spammish repetition")
>>> mh.intdigest()
7851180100622203313L

Note that the resulting hash value above is the same as in:

>>> mh = metrohash.CMetroHash64()
>>> mh.update("Nobody inspects the spammish repetition")
>>> mh.intdigest()
7851180100622203313L

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

metrohash-0.0.7.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

metrohash-0.0.7-cp27-none-macosx_10_10_x86_64.whl (20.1 kB view details)

Uploaded CPython 2.7macOS 10.10+ x86-64

File details

Details for the file metrohash-0.0.7.tar.gz.

File metadata

  • Download URL: metrohash-0.0.7.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for metrohash-0.0.7.tar.gz
Algorithm Hash digest
SHA256 4d572539e825230836288316199daae616b0e80e1e0a571973bdefe18a366834
MD5 cecca5f5312fc8464bb2fa33dca0c492
BLAKE2b-256 7f77ebd7ddce4931ae8d94be397836c0b64f56939e0aaae4fcf53ae1a42c1722

See more details on using hashes here.

File details

Details for the file metrohash-0.0.7-cp27-none-macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for metrohash-0.0.7-cp27-none-macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 75c99454c7a3a01ffddf209aca670f91239a8be28e4d35a565e29d8d5377c88e
MD5 13fe462187b09daf63d2735f3c37b833
BLAKE2b-256 9c7a119057a001cfc614d2bdb674f8d968fa8dc0bcbf69dfc691f2a81f4bf080

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page