hashver is a python module to derive a unique numeric value from a version string and vice versa
Project description
hashver
Is a python module to derive a unique numeric value from a version string and vice versa, adhering to following constraints:
- Resultant number must be unique for all possible values of a, b, c and d
- Each of a, b, c and d needs to be below certain maximum unsigned int guided by max possible bits allotted to each version component
- We should be able to derive unique a.b.c.d back from given number
- If a.b.c.d => x and p.q.r.s => y then, a.b.c.d < p.q.r.s => x < y
Usage
After performing python -m pip install hashver, execute python code as mentioned below.
>>> from hashver import HashVer
>>> hob = HashVer()
>>> hob.get_num('1.0.6')
4294967302
>>> hob.get_version_str(8590000133)
2.1.5
>>> # if your version is of format a.b.c.d, each of which should be at most 2^16
>>> hob = HashVer(bits_per_component='16.16.16.16')
>>> hob.get_num('9.0.100.10')
2533274796949514
>>> hob.get_version_str(2533274796949514)
9.0.100.10
Or if you have curl,
curl -skL https://raw.githubusercontent.com/ashutoshkumr/python-hashver/master/hashver/hashver.py | python - 1.0.6 8590000133
1.0.6 : 4294967302
8590000133 : 2.1.5
Modification and Testing
If any modification is done to hashver source, use following to validate changes,
# ensure various combinations of version string or number can be derived from each other
python -B ${hashver-root}/hashver.py 9.0.100.10 2533274796949514 --bpc 16.16.16.16
9.0.100.10 : 2533274796949514
2533274796949514: 9.0.100.10
# or simply add them to the existing test suite in hashver/test_hashver.py and run pytest
cd ${hashver-root} && pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hashver-0.0.2.tar.gz
(3.8 kB
view details)
File details
Details for the file hashver-0.0.2.tar.gz
.
File metadata
- Download URL: hashver-0.0.2.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5258de64b14556fee9c8aa05fcd759dd581939d13131515c62995f8f5f9aa885 |
|
MD5 | e24521045fa808c5016c3fcd6cd00448 |
|
BLAKE2b-256 | dc98f5ee72a374afaa832c0d7e4ed9b2b81530a18489af9a2a33a5e8bcf0ea54 |