module Pbkdf2PasswordHasher

Constants

VERSION

Public Class Methods

check_password(pass, hash) click to toggle source

Check password against hash string

# File lib/pbkdf2_password_hasher.rb, line 18
def check_password(pass, hash)
  DjangoHash.parse(hash).check_password(pass)
end
hash_password(pass, salt, nb_of_iterations, key_length = 32) click to toggle source

compute a hash from password, salt, number of iterations, and key length

# File lib/pbkdf2_password_hasher.rb, line 7
def hash_password(pass, salt, nb_of_iterations, key_length = 32)
  hsh = DjangoHash.new(
    :password => pass,
    :salt     => salt,
    :c        => nb_of_iterations,
    :dklen    => key_length
  ).get_hash
  "pbkdf2_sha256$#{nb_of_iterations}$#{salt}$#{hsh}"
end