https://github.com/dobatymo/metrohash-python
Python bindings for MetroHash.
https://github.com/dobatymo/metrohash-python
library non-cryptographic-hash-functions python
Last synced: 4 months ago
JSON representation
Python bindings for MetroHash.
- Host: GitHub
- URL: https://github.com/dobatymo/metrohash-python
- Owner: Dobatymo
- License: isc
- Created: 2019-05-27T04:28:39.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-09-03T22:03:01.000Z (almost 2 years ago)
- Last Synced: 2025-02-15T15:07:17.182Z (over 1 year ago)
- Topics: library, non-cryptographic-hash-functions, python
- Language: Python
- Homepage:
- Size: 62.5 KB
- Stars: 5
- Watchers: 3
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# metrohash-python
Python bindings for the fast non-cryptograpical hash function MetroHash. MetroHash C++ library by J. Andrew Rogers, Python bindings by Dobatymo.
## Requirements
The library has been tested on Linux Python 3.6, and on Windows Python 3.6, 3.7.
## Install
```
pip install metrohash-python
```
Compilation requires a C++ compiler and optionally `Cython`.
## Examples
The usage is similar to Python's hashlib.
```python
>>> import metrohash
>>> h = metrohash.MetroHash128()
>>> h.update(b'asd')
>>> h.update(b'qwe')
>>> h.digest()
b'K\xfb\x17\xeb>\xb2W\xbd\x93\xad\xf6\x17\xceg\x14\xda'
>>> h.hexdigest()
'4bfb17eb3eb257bd93adf617ce6714da'
```
Or as simple non-incremental function:
```python
>>> import metrohash
>>> metrohash.metrohash128(b'asdqwe')
b'K\xfb\x17\xeb>\xb2W\xbd\x93\xad\xf6\x17\xceg\x14\xda'
```
The interface for `MetroHash64` and `metrohash64` is the same.