Cloak.Model

Use this module to track the kind of encryption a row in your database was encrypted with.

Usage

Add a binary field to your Ecto module. It should be indexed, so that you can easily query on it.

schema "table" do
  field :encryption_version, :binary
end

You can then use this module, specifying the :encryption_version field as the one to store the value on:

use Cloak.Model, :encryption_version

The :encryption_version field will then automatically be reset with the current value of Cloak.version/0 every time a row is inserted or updated.