Skip to main content

hashver is a python module to derive a unique numeric value from a version string and vice versa

Project description

hashver Build Status

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


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')
>>> hob.get_version_str(8590000133)
>>> # if your version is of format a.b.c.d, each of which should be at most 2^16
>>> hob = HashVer(bits_per_component='')
>>> hob.get_num('')
>>> hob.get_version_str(2533274796949514)

Or if you have curl,

curl -skL | 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}/ 2533274796949514 --bpc : 2533274796949514

# or simply add them to the existing test suite in hashver/ and run pytest
cd ${hashver-root} && pytest

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for hashver, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size hashver-0.0.2.tar.gz (3.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page