An extension for encrypting attributes of a resource.

See the getting started guide for more information.

cloak

Encrypt attributes of a resource

Options

NameTypeDefaultDocs
vaultmodule | (any, any -> any) | mfaThe vault to use to encrypt & decrypt the value. Accepts a module implementing Cloak.Vault, a fun/2 of the form (resource_module, context) -> vault_module, or an MFA tuple. When a function or MFA is given, it is called at every encrypt and decrypt operation and its return value is used as the vault module.
attributesatom | list(atom)[]The attribute or attributes to encrypt. The attribute will be renamed to encrypted_{attribute}, and a calculation with the same name will be added.
decrypt_by_defaultatom | list(atom)[]A list of attributes that should be decrypted (their calculation should be loaded) by default.
on_decrypt(any, any, any, any -> any) | mfaA function to call when decrypting any value. Takes the resource, field, records, and calculation context. Must return :ok or {:error, error}