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