A python port of the JavaScript hashids implementation. It generates YouTube-like hashes from one or many numbers. Use hashids when you do not want to expose your database ids to the user. Website: http:/www.hashids.org/
Compatibility
hashids is tested with python 2.7 and 3.5–3.8. PyPy and PyPy 3 work as well.
Compatibility with the JavaScript implementation
hashids/JavaScript
hashids/Python
v0.1.x
v0.8.x
v0.3.x+
v1.0.2+
The JavaScript implementation produces different hashes in versions 0.1.x and 0.3.x. For compatibility with the older 0.1.x version install hashids 0.8.4 from pip, otherwise the newest hashids.
Installation
Install the module from PyPI, e. g. with pip:
pip install hashids
pip install hashids==0.8.4 # for compatibility with hashids.js 0.1.x
Run the tests
The tests are written with pytest. The pytest module has to be installed.
python -m pytest
Usage
Import the constructor from the hashids module:
from hashids import Hashids
hashids = Hashids()
Basic Us
|