decrypt challenge - perl encrypt with ruby decrypt

Discussion in 'Ruby' started by aktxyz@gmail.com, Jun 13, 2007.

  1. Guest

    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
    , Jun 13, 2007
    #1
    1. Advertising

  2. "Nathan Taylor-Hoover" <> writes:

    > 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.
    Daniel Martin, Jun 16, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    482
    Jonathan Allen
    Sep 25, 2004
  2. Mark

    Encrypt/decrypt info from form

    Mark, Feb 6, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,492
    William LaMartin
    Feb 6, 2004
  3. Maran Chandrasekar

    Perl Encrypt / Ruby Decrypt

    Maran Chandrasekar, Feb 16, 2009, in forum: Ruby
    Replies:
    1
    Views:
    252
    Brian Candler
    Feb 16, 2009
  4. http://ejobseek.com

    Encrypt in Perl, De-encrypt in Javascript

    http://ejobseek.com, Sep 1, 2003, in forum: Perl Misc
    Replies:
    3
    Views:
    269
    James Willmore
    Sep 1, 2003
  5. uncle
    Replies:
    2
    Views:
    134
    Michele Dondi
    Jun 16, 2007
Loading...

Share This Page