calypso.utils.hash module

calypso.utils.hash.hash_str(s, algo='sha256') str
calypso.utils.hash.hash_uints(uints, algo='sha256') str

Hash a list of non-negative integers

Parameters:
  • uints (Sequence[int]) – A list of int.

  • algo (str, optional) – Hash algorithom, by default “sha1”.

Returns:

Hash string.

Return type:

str

Examples

>>> hash_uints([1, 2, 3])
'WklgTrrOsQ8Sp8ZR6EqPqrbEKj0m6Je9U7zu-3vE1Gl'
calypso.utils.hash.uint2base64(n: int) str

Base64-encoding non-negative integer

Parameters:

n (int) – Non-negative integer.

Returns:

Base64-encoded string.

Return type:

str

Raises:

ValueError – n is negative

Examples

>>> uint2base64(0)
'a'
>>> list(map(uint2base64, [0, 25, 26, 51, 52, 61, 62, 63, 64]))
['a', 'z', 'A', 'Z', '0', '9', '-', '_', 'ab']