Pbkdf2.Base (pbkdf2_elixir v1.4.0) View Source

Base module for the Pbkdf2 password hashing library.

Link to this section Summary

Functions

django_salt(len) deprecated

Hash a password using Pbkdf2.

Verify a password by comparing it with the stored Pbkdf2 hash.

Link to this section Functions

This function is deprecated. Use Pbkdf2.gen_salt/1 (with `format: :django`) instead.
Link to this function

hash_password(password, salt, opts \\ [])

View Source

Specs

hash_password(binary(), binary(), keyword()) :: binary()

Hash a password using Pbkdf2.

Options

There are four options (rounds can be used to override the value in the config):

  • :rounds - the number of rounds
    • the amount of computation, given in number of iterations
    • the default is 160_000
    • this can also be set in the config file
  • :format - the output format of the hash
    • the default is :modular - modular crypt format
    • the other available formats are:
      • :django - the format used in django applications
      • :hex - the hash is encoded in hexadecimal
  • :digest - the sha algorithm that pbkdf2 will use
    • the default is sha512
  • :length - the length, in bytes, of the hash
    • the default is 64 for sha512 and 32 for sha256
Link to this function

verify_pass(password, hash, salt, digest, rounds, output_fmt)

View Source

Specs

verify_pass(binary(), binary(), binary(), atom(), binary(), atom()) :: boolean()

Verify a password by comparing it with the stored Pbkdf2 hash.