DES3 decryption in Ruby on Rails

Posted by AntonAL on Stack Overflow See other posts from Stack Overflow or by AntonAL
Published on 2010-01-11T17:26:46Z Indexed on 2010/03/08 18:21 UTC
Read the original article Hit count: 1286

My RoR server receives a string, that was encrypted in C++ application using des3 with base64 encoding

The cipher object is created so:

cipher = OpenSSL::Cipher::Cipher::new("des3")
cipher.key = key_str
cipher.iv =  iv_str

key_str and iv_str: are string representations of key and initialization vector for encryption algorithm. They are the same for RoR and C++ application.

The code on the RoR side is following:

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 ?

© Stack Overflow or respective owner

Related posts about ruby

Related posts about ruby-on-rails