Method: OnePassword::Encryption.decrypt_using_pbkdf2
- Defined in:
- lib/one_password/encryption.rb
.decrypt_using_pbkdf2(data, password, iterations) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/one_password/encryption.rb', line 12 def self.decrypt_using_pbkdf2(data, password, iterations) encrypted = Base64.decode64(data) salt = ZERO_IV if salted?(encrypted) salt = encrypted[8, 8] encrypted = encrypted[16..-1] end derived_key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(password, salt, iterations, 32) key = derived_key.slice(0..15) iv = derived_key.slice(16..-1) decrypt_using_key_and_ivec(encrypted, key, iv) end |