Ruby on Rails Decryption
Posted
by
user812120
on Stack Overflow
See other posts from Stack Overflow
or by user812120
Published on 2012-04-11T11:25:59Z
Indexed on
2012/04/11
11:30 UTC
Read the original article
Hit count: 407
0 down vote favorite share [g+] share [fb] share [tw]
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.
mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $privateKey, base64_decode($enc), MCRYPT_MODE_CBC, $iv)
I tried to use the following in Ruby but got a bad decrypt error.
cipher = OpenSSL::Cipher.new('aes-256-cbc')
cipher.decrypt
cipher.key = privateKey
cipher.iv = iv
decrypted = '' << cipher.update(encrypted) << cipher.final
© Stack Overflow or respective owner