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())
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())
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)
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)