[![Hex Version](](
[![Build Status](](
[![Inline docs](](

Cloak makes it easy to use encryption with Ecto.

## Features

- Transparent encryption/decryption of fields
- Bring your own encryptor (if needed)
- Zero-downtime migration to new encryption keys
    - Multiple keys in memory at once
    - Migration task to proactively migrate rows to a new key

## Example

# in config/config.exs
config :cloak, Cloak.AES.CTR,
  tag: "AES",
  default: true,
  keys: [
    %{tag: <<1>>, key: :base64.decode("..."), default: true}

# in your model
defmodule MyApp.Model do
  use Ecto.Model
  use Cloak.Model, :encryption_version

  schema "models" do
    field :field_name, Cloak.EncryptedBinaryField
    field :encryption_version, :binary

# Query
# => %MyApp.Model{field_name: "Decrypted value", encryption_version: <<"AES", 1>>}

## Installation

Add `cloak` to your hex dependencies:

defp deps do
  [{:cloak, "~> 0.1.0"}]

## Documentation

See [the hex documentation](