GitHub

CipherService

API reference for CipherService.

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, *, iv) -> Effect[bytes, CryptoError]

The ciphertext of plaintext under key and the 16-byte iv.

ParameterTypeDescription
keyKey[Any]
plaintextBinary
ivBinary

Returns Effect[bytes, CryptoError]

def encrypt(
    self, key: Key[Any], plaintext: Binary, *, iv: Binary
) -> Effect[bytes, CryptoError]:
    """The ciphertext of ``plaintext`` under ``key`` and the 16-byte ``iv``."""
    ...

decrypt

decrypt(key, ciphertext, *, iv) -> Effect[bytes, CryptoError]

The plaintext; AES-CBC fails a bad padding or length with DecryptionFailed, AES-CTR never fails.

ParameterTypeDescription
keyKey[Any]
ciphertextBinary
ivBinary

Returns Effect[bytes, CryptoError]

def decrypt(
    self, key: Key[Any], ciphertext: Binary, *, iv: Binary
) -> Effect[bytes, CryptoError]:
    """The plaintext; AES-CBC fails a bad padding or length with
    ``DecryptionFailed``, AES-CTR never fails."""
    ...