lib/gooddata/helpers/global_helpers.rb
# encrypts data with the given key. returns a binary data with the
# unhashed random iv in the first 16 bytes
encrypts data with the given key. returns a binary data with the
unhashed random iv in the first 16 bytes
encrypts data with the given key . returns a binary data with the unhashed random iv in the first 16 bytes
def encrypt(data, key)
        cipher = OpenSSL::Cipher::Cipher.new('aes-256-cbc')
        cipher.encrypt
        cipher.key = key = Digest::SHA256.digest(key)
        random_iv = cipher.random_iv
        cipher.iv = Digest::SHA256.digest(random_iv + key)[0..15]
        encrypted = cipher.update(data)
        encrypted << cipher.final
        Base64.encode64(random_iv + encrypted)
      end
def encrypt ( data , key ) cipher = OpenSSL :: Cipher :: Cipher . new ( 'aes-256-cbc' ) cipher . encrypt cipher . key = key = Digest :: SHA256 . digest ( key ) random_iv = cipher . random_iv cipher . iv = Digest :: SHA256 . digest ( random_iv + key ) [ 0 .. 15 ] encrypted = cipher . update ( data ) encrypted << cipher . final Base64 . encode64 ( random_iv + encrypted ) end
encrypts data with the given key.
encrypts data with the given key .
# add unhashed iv to front of encrypted data
data
key