Hi Guys, I'm trying to do some triple DES encryption in Ruby. I'm trying to replicate the results from this page: http://da.nmilne.com/des.html
I'm trying to replicate those result in Ruby. I suspect the problem is the key is supposed to be a string, but I need to pass in a Hexadecimal key. Either that or the string being encrypted is in the wrong format. Or maybe both. :-)
require 'openssl'
des = OpenSSL::Cipher::Cipher.new("des-ede-cbc")
des.encrypt
des.key="23232323232323234545454545454545"
des.update("0000000000000000")
res=des.final
res.unpack('H*')
=> ["5045c5d37ca4d13b"]
But it should be:
=> ["3a42d7a1d1c60c40"]
Any pointers on where I'm going wrong?
- Different 3DES algorithms are documented here: http://www.openssl.org/docs/apps/enc.html
- Edited for clarity