Hi All.

I am experiencing a rather strange problem using
mcrypt with php. We store our passwords in a
SQL database. The passwords are encrypted with
the following code at a SuSe7.1 System (php4.04 or php 4.06):

function encryptData($data, $p) {
  $iIV = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256,MCRYPT_MODE_ECB), 
MCRYPT_RAND);
  $sEncrypted = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $p, $data, MCRYPT_MODE_ECB, 
$iIV);
  return(base64_encode($sEncrypted));
}

the decryption works like this

function decryptData($data, $p) {
  $data = base64_decode($data);
  $iIV = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), 
MCRYPT_RAND);
  $sDecrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $p, $data, MCRYPT_MODE_ECB, $iIV);
  return(trim($sDecrypted));
}


recently we upgraded our machine to SuSe 8.1 (php4.2.2). The problem is, that the 
decryption of data does 
not work anymore. I figured out that I have to change MCRYPT_RIJNDAEL_256 to 
MCRYPT_RIJNDAEL_128
in order to get fragments of the encrypted text decoded:

function decryptData($data, $p) {
  $data = base64_decode($data);
  $iIV = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB), 
MCRYPT_RAND);
  $sDecrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $p, $data, MCRYPT_MODE_ECB, $iIV);
  return(trim($sDecrypted));
}


the result looks like that:

www.cyberport.deŒò§v§ÉœlÝh(se
passwd: 33307‰#Cžú´Ÿê"ØÙåXÙG4798

(some info is correct some is scrambled)


Can anybody help retreaving our passwords? Does anybody has a hint, is there 
a known bug? Is this a character encoding problem?


Please help.


Best regards.


Joachim Müller


____________________________________________

joachim müller
[EMAIL PROTECTED] . tel +49-69-759003-11

wemove digital solutions
[EMAIL PROTECTED]  . tel +49-69-759003-0 .  fax +49-69-759003-22
eschersheimer landstrasse 5 
60322 frankfurt . germany
http://www.wemove.com/


Reply via email to