cloak v0.7.0 Cloak.Cipher behaviour View Source

A behaviour for encryption/decryption modules. Use it to write your own custom Cloak-compatible cipher modules.

Link to this section Summary

Callbacks

Determines if a given ciphertext can be decrypted by this cipher

Decrypt a value, using the given opts

Encrypt a value, using the given opts

Link to this section Types

Link to this section Callbacks

Link to this callback can_decrypt?(ciphertext, opts) View Source
can_decrypt?(ciphertext(), opts()) :: boolean()

Determines if a given ciphertext can be decrypted by this cipher.

Link to this callback decrypt(ciphertext, opts) View Source
decrypt(ciphertext(), opts()) :: {:ok, binary()} | :error

Decrypt a value, using the given opts.

Link to this callback encrypt(plaintext, opts) View Source
encrypt(plaintext(), opts()) :: {:ok, binary()} | :error

Encrypt a value, using the given opts.

Your implementation must include any information it will need for decryption in the generated ciphertext.