28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/one_password/encryption.rb', line 28
def self.decrypt_using_key(encrypted, encryption_key)
encrypted = Base64.decode64(encrypted)
if Encryption.salted?(encrypted)
salt = encrypted[8, 8]
encrypted = encrypted[16..-1]
key, iv = Encryption.open_ssl_key(encryption_key, salt)
else
key = OpenSSL::Digest::MD5.digest(encryption_key)
iv = Encryption::ZERO_IV
end
plain_text = Encryption.decrypt_using_key_and_ivec(encrypted, key, iv)
CGI::unescape(CGI::escape(plain_text))
end
|