Skip to content

scrogson/key_generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KeyGenerator

KeyGenerator is a PBKDF2 implementation for Elixir. Conforming to rfc2898.

It can be used to derive a number of keys for various purposes from a given secret. This lets applications have a single secure secret, but avoid reusing that key in multiple incompatible contexts.

Usage

defmodule User do
  import KeyGenerator

  def encrypt_password(password, salt, opts \\ []) do
    generate(password, salt, opts) |> to_hex
  end
end

key = User.encrypt_password("password", "salt")
# => "f87cbb89d972a9b96f5a9e2068308f06e1cf6421748..."

Options

  • :iterations - defaults to 1000;
  • :length - a length in octets for the derived key. Defaults to 64;
  • :digest - an hmac function to use as the pseudo-random function. Defaults to :sha;

About

PBKDF2 implementation for Elixir

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages