Method: Cnvrg::Helpers#decrypt

Defined in:
lib/cnvrg/helpers.rb

#decrypt(key, iv, str) ⇒ Object



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/cnvrg/helpers.rb', line 266

def decrypt(key, iv, str)
  begin

    cipher = OpenSSL::Cipher.new("aes-256-cbc").decrypt
    cipher.key = key
    cipher.iv = Base64.decode64 iv.encode('utf-8')

    result = Base64.decode64 (str.encode('utf-8'))
    result = cipher.update(result)
    result << cipher.final
    return result.force_encoding('utf-8')

    # return result
  rescue => e
    puts e

  end

end