/ex_pbkdf2

Password-Based Key Derivation Function v2 (PBKDF2) for Elixir by a Rust-based NIF

Primary LanguageElixirMIT LicenseMIT

ExPBKDF2

Rust NIf for Password-Based Key Derivation Function v2 (PBKDF2). It uses the pbkdf2 rust library.

Installation

The package can be installed by adding ex_pbkdf2 to your list of dependencies in mix.exs:

def deps do
  [
    {:ex_pbkdf2, "~> 0.8"}
  ]
end

Usage

EXPBKDF2 provides three functions:

  • generate_salt/1 - generates salt that can be used in pbkdf2/2
  • pbkdf2/2 - hashes the provided password
  • verify/3 - verifies the hash

The docs can be found at https://hexdocs.pm/ex_pbkdf2.

Benchmarks

This NIF is 5 times faster than pbkdf2_elixir - 4.48 ms vs 22.89.ms. It also performs better in terms of used memory. Benchmarks can be found in the benchmarks directory

Contributing

  1. Fork it!
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Author

Ayrat Badykov (@ayrat555)