Skip to content
Ecto type for saving encrypted passwords using Comeonin
Elixir
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
config
lib
test
.gitignore
.travis.yml travis ci Jan 22, 2016
LICENSE
README.md
mix.exs
mix.lock

README.md

Comeonin Ecto Password

A custom Ecto type for storing encrypted passwords using Comeonin

For ecto 2 compatibility use the ecto-2 branch or version 2.0.0-rc0

Usage

On your schema, define secure fields with this type:

field :password, Comeonin.Ecto.Password

Then on your changeset simply cast from plain-text params

cast(changeset, params, ~w(password), ~w())

After casting the password will already be encrypted in the changeset, and can be saved to your table's string column.

To check for validity, do something like:

user = Repo.get_by User, email: "me@example.org"
Comeonin.Ecto.Password.valid?("plain_password", user.password)

Configuration

In your environment file, choose one of Comeonin.Pbkdf2 or Comeonin.Bcrypt

config :comeonin, Ecto.Password, Comeonin.Pbkdf2

# when using pkbdf2
config :comeonin, :pbkdf2_rounds, 120_000
config :comeonin, :pbkdf2_salt_len, 512

# when using bcrypt
config :comeonin, :bcrypt_log_rounds, 14

Also, be sure to look at comeonin config

Installation

Available in Hex, the package can be installed as:

  1. Add comeonin_ecto_password to your list of dependencies in mix.exs:
def deps do
  [{:comeonin_ecto_password, "~> 0.0.3"}]
end
  1. Ensure comeonin is started before your application:
def application do
  [applications: [:comeonin]]
end
Something went wrong with that request. Please try again.