[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

decrypt challenge - perl encrypt with ruby decrypt

uncle

6/13/2007 10:57:00 PM

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";

>> string=%0AP%91%06%0APq%7D%12%E83%DD%87%1C%7Cz




#========================= 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)

>> %ABL%3E%04F%FA%83%9A%C0%CB%A7Z5%FCb%E9

1 Answer

Daniel Martin

6/16/2007 1:30:00 PM

0

"Nathan Taylor-Hoover" <onebitcipher@gmail.com> writes:

> The problem with your code is that you are using two different encryption
> algorithims.

Not quite; see http://www.openssl.org/docs/app... - 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.