Beispiel #1
0
def _do_digest(data, func):
    """Return the binary digest of `data` with the given `func`."""
    func = FuncReg.get(func)
    hash = FuncReg.hash_from_func(func)
    if not hash:
        raise ValueError("no available hash function for hash", func)
    hash.update(data)
    return bytes(hash.digest())
Beispiel #2
0
def _do_digest(data, func):
    """Return the binary digest of `data` with the given `func`."""
    func = FuncReg.get(func)
    hash = FuncReg.hash_from_func(func)
    if not hash:
        raise ValueError("no available hash function for hash", func)
    hash.update(data)
    return bytes(hash.digest())
Beispiel #3
0
 def __new__(cls, func, digest):
     try:
         func = FuncReg.get(func)
     except KeyError:
         if _is_app_specific_func(func):
             # Application-specific function codes
             # are allowed even if not registered.
             func = int(func)
         else:
             raise
     digest = bytes(digest)
     return super(cls, Multihash).__new__(cls, func, digest)
Beispiel #4
0
 def __new__(cls, func, digest):
     try:
         func = FuncReg.get(func)
     except KeyError:
         if _is_app_specific_func(func):
             # Application-specific function codes
             # are allowed even if not registered.
             func = int(func)
         else:
             raise
     digest = bytes(digest)
     return super(cls, Multihash).__new__(cls, func, digest)