forked from hashdist/hashdist
-
Notifications
You must be signed in to change notification settings - Fork 0
Hashing
certik edited this page Apr 1, 2012
·
4 revisions
We decided to use SHA1 (180-bit) hashes with base64 encoding (modified to be file-system safe; with -, _ as extra non-alphabet characters, we do not need padding).
This allows our hashes to be shorter than git, and, more importantly, visually distinguishes the hashes from those of git.
Hashes are easily computed using the hashlib and base64 Python modules.
Example:
import hashlib
import base64
h = hashlib.sha1()
h.update('TO HASH')
h.update('ALSO HASH THIS')
base64.b64encode(h.digest(), altchars='-_').replace('=', '')
Output:
Out[8]: 'mheIiqyFVX61qnGc53ZhR-uqVsY'