Module: CryptKeeper::Helper::DigestPassphrase
- Included in:
- Provider::MysqlAesNew
- Defined in:
- lib/crypt_keeper/helper.rb
Instance Method Summary collapse
-
#digest_passphrase(key, salt) ⇒ Object
Public: Generates a hex passphrase using the given key and salt.
Instance Method Details
#digest_passphrase(key, salt) ⇒ Object
Public: Generates a hex passphrase using the given key and salt.
key - Encryption key salt - Encryption salt
Returns a String.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/crypt_keeper/helper.rb', line 72 def digest_passphrase(key, salt) raise ArgumentError.new("Missing :key") if key.blank? raise ArgumentError.new("Missing :salt") if salt.blank? require "openssl" digest = OpenSSL::Digest.new(hash_algorithm) hmac = OpenSSL::PKCS5.pbkdf2_hmac( key, salt, iterations, digest.digest_length, digest ) hmac.unpack("H*").first end |