I am using rails 3.2, Ruby 1.9.3 and the encrypted_strings gem, when try the following:
"wC6234sdf234234cCY1Lag==\n".decrypt(:symmetric, :key => "mykeynottelling")
I get this error:
OpenSSL::Cipher::CipherError: bad decrypt
This does not however happen with Ruby 1.8.7. I'm a little lost on this, does anyone see what might be causing this?
UPDATE 1:
If I encrypt a string in ruby 1.8.7:
"password".encrypt(:symmetric, :key => "www.buyandsell.ie") # output is "hr0aZUZTa7x1gQL8ZMI/dQ==\n"
and try to decrypt that in ruby 1.9.2 I get a "bad decrypt" error, but I if paste it into my IRB console in ruby 1.8.7 and try to decrypt it, it works.
Update 2:
OpenSSL is different between my ruby 1.9.3 and 1.8.7 boxes, could this cause this error?
I had a similar issue upgrading from 1.9.3 to 2.2.2 dealing with the Symmetric Encryption gem. The root cause ended up being the fact that the gem used Ruby's marshaling library, which had changed between versions.
I ultimately had to decrypt all of the data in 1.9.3 before upgrading to 2.2.2, which proved to be a miserable experience.
From the docs,
Marshaled data has major and minor version numbers stored along with the object information. In normal use, marshaling can only load data written with the same major version number and an equal or lower minor version number.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With