The following function works perfect in PHP. How can it be translated in Ruby on Rails.
Please note that both privateKey and iv are 32 characters long.
m
Here some code which works for me :
def decrypt_data(data, pwd, iv)
encrypted_data = Base64.decode64(data)
aes = OpenSSL::Cipher::Cipher.new("AES-256-CBC")
aes.decrypt
aes.key = Digest::MD5.hexdigest(pwd)
aes.iv = iv
result = aes.update(encrypted_data) + aes.final
end
In my example the password is encrypted with MD5.
I hope this help