sha#

sha(obj, digest=False, asint=False, encoding='utf-8')[source]#

Shortcut for the standard hashing (SHA) method

Equivalent to hashlib.sha224().

Parameters:
  • obj (any) – the object to be hashed; if not a string, converted to one

  • digest (bool) – if True, return the hex digest instead of the hash object

  • asint (bool) – if True, return the (very large) integer corresponding to the hex digest

  • encoding (str) – the encoding to use

Example:

sha1 = sc.sha(dict(foo=1, bar=2), True)
sha2 = sc.sha(dict(foo=1, bar=2), digest=True)
sha3 = sc.sha(dict(foo=1, bar=3), digest=True)
assert sha1 == sha2
assert sha2 != sha3
New in version 3.2.0: “asint” argument; changed argument order