Method: OpenNebula.decrypt

Defined in:
lib/opennebula/utils.rb

.decrypt(res, token) ⇒ Object

receive hashed values (res) with a token returns original values



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/opennebula/utils.rb', line 37

def self.decrypt(res, token)
    opts = {}

    res.each do |key, encrypted_value|
        decipher = OpenSSL::Cipher::AES.new(256,:CBC)
        decipher.decrypt
        decipher.key = token[0..31]
        plain = decipher.update(Base64::decode64(encrypted_value)) + decipher.final
        opts[key] = plain
    end
    return opts
end