GitHub

DigestService

API reference for DigestService.

The Digest service: layer_web_crypto and native build it, and DigestService(digest=..., digest_hex=...) makes one of two functions.

Functions

__init__

__init__(*, digest, digest_hex) -> None
ParameterTypeDescription
digestCallable[[Algorithm, Binary], Effect[bytes]]
digest_hexCallable[[Algorithm, Binary], Effect[str]]
def __init__(
    self,
    *,
    digest: Callable[[Algorithm, Binary], Effect[bytes]],
    digest_hex: Callable[[Algorithm, Binary], Effect[str]],
) -> None:
    self._digest = digest
    self._digest_hex = digest_hex

digest

digest(algorithm, data) -> Effect[bytes]

algorithm's digest of data.

ParameterTypeDescription
algorithmAlgorithm
dataBinary

Returns Effect[bytes]

def digest(self, algorithm: Algorithm, data: Binary) -> Effect[bytes]:
    """``algorithm``'s digest of ``data``."""
    return self._digest(algorithm, data)

digest_hex

digest_hex(algorithm, data) -> Effect[str]

algorithm's digest of data, as lowercase hex.

ParameterTypeDescription
algorithmAlgorithm
dataBinary

Returns Effect[str]

def digest_hex(self, algorithm: Algorithm, data: Binary) -> Effect[str]:
    """``algorithm``'s digest of ``data``, as lowercase hex."""
    return self._digest_hex(algorithm, data)