My RoR server receives a string that has been encrypted in a C ++ application using des3 base64 encoded
The encryption object is created as follows:
cipher = OpenSSL::Cipher::Cipher::new("des3")
cipher.key = key_str
cipher.iv = iv_str
key_str and iv_str: are string representations of the key and initialization vector for the encryption algorithm. They are the same for RoR and C ++ applications.
The code on the RoR side is as follows:
result = ""
result << cipher.update( Base64.decode64(message) )
result << cipher.final
After executing the last line of code, I get an exception
OpenSSL::CipherError (bad decrypt)
What is wrong here? Any ideas?
source
share