Hello list,

Hopping anyone can help me. I am trying to encrypt using 3Des algorithm.

My test key encryption is 'sq7HjrUOBfKmC576ILgskD5srU870gJ7' (Base64encoded)
And I want to encrypt the string '28580'

I am using this code

var d3des: TSyna3Des;
begin
   d3des := 
TSyna3Des.Create(DecodeBase64('sq7HjrUOBfKmC576ILgskD5srU870gJ7'));
   try
     Memo4.Lines.Append(EncodeBase64(d3des.EncryptCBC('28580')));
   finally
     d3des.free;
   end;

And I get 'TpLFbMQ='

The problem is that it is a different result from the PHP code:

     function encrypt_3DES($message, $key){
         $bytes = array(0,0,0,0,0,0,0,0); //byte [] IV = {0, 0, 0, 0, 0, 
0, 0, 0}
         $iv = implode(array_map("chr", $bytes)); //PHP 4 >= 4.0.2
         $ciphertext = mcrypt_encrypt(MCRYPT_3DES, $key, $message, 
MCRYPT_MODE_CBC, $iv); //PHP 4 >= 4.0.2
         return $ciphertext;
     }

Using PHP and Encoded in Base64 the result is 'OKAVCoyT0wE='

Why I get different results?

Thank you for your time,
Alex



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public

Reply via email to