Cryppo.encrypt
You're seeing just the function
encrypt
, go back to Cryppo module for more information.
Specs
encrypt(binary(), encryption_strategy()) :: Cryppo.EncryptedData.t() | {:unsupported_encryption_strategy, atom()} | :encryption_error | {:encryption_error, any()}
Generate an encryption key for an encryption strategy and encrypt data with this encryption key
Example
iex> {_encrypted_data, _encryption_key} = Cryppo.encrypt("data to encrypt", "Aes256Gcm")
Specs
encrypt(binary(), encryption_strategy(), Cryppo.EncryptionKey.t() | any()) :: Cryppo.EncryptedData.t() | {:unsupported_encryption_strategy, atom()} | {:error, :invalid_encryption_key} | :encryption_error | {:incompatible_key, [submitted_key_strategy: atom(), encryption_strategy: atom()]}
Encrypt data with an encryption key
Example
iex> encryption_key = Cryppo.generate_encryption_key("Aes256Gcm")
iex> _encrypted_data = Cryppo.encrypt("data to encrypt", "Aes256Gcm", encryption_key)
The encryption key must match the encryption strategy:
iex> encryption_key = Cryppo.generate_encryption_key("Aes256Gcm")
iex> Cryppo.encrypt("data to encrypt", "Rsa4096", encryption_key)
{:incompatible_key, [submitted_key_strategy: Cryppo.Aes256gcm, encryption_strategy: Cryppo.Rsa4096]}