2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-03-06 07:12:16 -05:00
|
|
|
class Pbkdf2
|
2023-04-05 12:00:05 -04:00
|
|
|
def self.hash_password(password, salt, iterations, algorithm = "sha256", length: 32)
|
|
|
|
OpenSSL::KDF.pbkdf2_hmac(
|
|
|
|
password,
|
|
|
|
salt: salt,
|
|
|
|
iterations: iterations,
|
|
|
|
length: length,
|
|
|
|
hash: algorithm,
|
|
|
|
).unpack1("H*")
|
2013-03-06 07:12:16 -05:00
|
|
|
end
|
|
|
|
end
|