cloak v0.7.0-alpha.1 Cloak.Fields.Map View Source

An Ecto.Type to encrypt maps.

Configuration

You can customize the json library used for for converting the lists.

config :my_app, MyApp.Vault,
  json_library: Jason

Usage

defmodule MyApp.Encrypted.Map do
  use Cloak.Fields.Map, vault: MyApp.Vault
end

You should create the field with type :binary. On encryption, the map 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 map.

This means that on decryption, atom keys will become string keys.

%{hello: "world"}

Will become:

%{"hello" => "world"}