decrypt challenge - perl encrypt with ruby decrypt

A

aktxyz

Ok, so I am trying integrate with someone who is sending me a string
that is triple des encrypted thru perl.
I need to decrypt the string thru ruby.

I have had no luck decrypting, so decided I would try to encrypt in
ruby as a sanity check...of course...I get different results.

HELP please :)

Here is the perl...then the ruby. Oh yes, and I am so glad there are
no ; in ruby !


#========================= perl
use Crypt::TripleDES;
use URI::Escape;

my $key="AKJSAYOQWOEIQWLEKJQLKNDDOIQQLWEL";
my $token="1234567890";

my $des = new Crypt::TripleDES;
my $string= $des->encrypt3($token,$key);
#print "string=$string\n\n";
$string=uri_escape($string);
print "string=$string\n\n";




#========================= ruby
require 'openssl'
require 'cgi'
require 'uri'

key = "AKJSAYOQWOEIQWLEKJQLKNDDOIQQLWEL"
token = "1234567890"

e = OpenSSL::Cipher::Cipher.new 'DES-EDE3'
e.encrypt key
s = e.update token
s << e.final
puts URI.escape(s)
 
D

Daniel Martin

Nathan Taylor-Hoover said:
The problem with your code is that you are using two different encryption
algorithims.

Not quite; see http://www.openssl.org/docs/apps/enc.html - in brief:

des-ede3-cbc Three key triple DES EDE in CBC mode
des-ede3 Three key triple DES EDE in ECB mode
des3 Alias for des-ede3-cbc
des-ede3-cfb Three key triple DES EDE CFB mode
des-ede3-ofb Three key triple DES EDE in OFB mode

So the cipher being used should in theory work, but it clearly doesn't
at all. I can't find any decent information relating what
Crypt:TripleDES does to an equivalent operation for openssl. (openssl
in ruby or otherwise) I also don't know that passing the key as the
argument to encrypt is the appropriate behavior.

Openssl has both keys and initial values, which are derived from
passphrases in a manner I don't understand. Crypt::TripleDES uses
only a key, and I don't know how those two correspond to each other.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top