Method: OpenNebula.encrypt

Defined in:
lib/opennebula/utils.rb

.encrypt(opts, token) ⇒ Object

receive a object key => value format returns hashed values



24
25
26
27
28
29
30
31
32
33
# File 'lib/opennebula/utils.rb', line 24

def self.encrypt(opts, token)
    res = {}
    opts.each do |key, value|
        cipher = OpenSSL::Cipher::AES.new(256,:CBC)
        cipher.encrypt.key = token[0..31]
        encrypted = cipher.update(value) + cipher.final
        res[key] = Base64::encode64(encrypted).gsub("\n", "")
    end
    return res
end