GitHub

AeadService

API reference for AeadService.

Functions

generate_key

generate_key[A: Algorithm](algorithm) -> Effect[Key[A], CryptoError]

A key of random bytes from SecureRandom.

ParameterTypeDescription
algorithmA

Returns Effect[Key[A], CryptoError]

def generate_key[A: Algorithm](self, algorithm: A) -> Effect[Key[A], CryptoError]:
    """A key of random bytes from ``SecureRandom``."""
    ...

encrypt

encrypt(key, plaintext, *, nonce, aad=None) -> Effect[bytes, CryptoError]

The ciphertext followed by its 16-byte tag.

ParameterTypeDescription
keyKey[Any]
plaintextBinary
nonceBinary
aadBinary | None = None

Returns Effect[bytes, CryptoError]

def encrypt(
    self, key: Key[Any], plaintext: Binary, *, nonce: Binary, aad: Binary | None = None
) -> Effect[bytes, CryptoError]:
    """The ciphertext followed by its 16-byte tag."""
    ...

decrypt

decrypt(key, ciphertext, *, nonce, aad=None) -> Effect[bytes, CryptoError]

The plaintext; DecryptionFailed for any authentication failure.

ParameterTypeDescription
keyKey[Any]
ciphertextBinary
nonceBinary
aadBinary | None = None

Returns Effect[bytes, CryptoError]

def decrypt(
    self, key: Key[Any], ciphertext: Binary, *, nonce: Binary, aad: Binary | None = None
) -> Effect[bytes, CryptoError]:
    """The plaintext; ``DecryptionFailed`` for any authentication failure."""
    ...