View Source Cloak.Ecto.StringList (cloak_ecto v1.3.0)
An Ecto.Type to encrypt a list of strings.
Configuration
You can customize the json library used for for converting lists.
config :my_app, MyApp.Vault,
json_library: JasonMigration
The database field must be of type :binary.
add :encrypted_field, :binaryUsage
Define an Encrypted.StringList module in your project:
defmodule MyApp.Encrypted.StringList do
use Cloak.Ecto.StringList, vault: MyApp.Vault
endThen, define the type of your desired fields:
schema "table_name" do
field :encrypted_field, MyApp.Encrypted.StringList
endOn encryption, the list will first be converted to JSON using the configured
:json_library, and then encrypted. On decryption, the :json_library will
be used to convert it back to a list of strings.