note 78764 deleted from ref.mcrypt by danbrown

From: Date: Mon, 13 Dec 2010 16:20:31 +0000
Subject: note 78764 deleted from ref.mcrypt by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174849@lists.php.net to get a copy of this message
Note Submitter: mre (at) reinhardt (dot) info ---- Here are my functions to do a 128 bit aes encryption which is transmitted to the dachser parcel tracking system via url. They expect a true aes 128 bit encryption an process the reqest by a java script. The decrypt function is just a giveaway. function aes_128_encrypt($text,$password) { $size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); $iv = mcrypt_create_iv($size, MCRYPT_DEV_RANDOM); // The following line was needed because I didn't get the same hex value as expected by forwarding agency // I think its their bug // Try to remove the line. If it works, too - fine! $text .= chr(3).chr(3).chr(3); return bin2hex(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $password, $text, MCRYPT_MODE_ECB, $iv)); } // End of function function aes_128_decrypt($encrypted_text,$password) { $size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); $iv = mcrypt_create_iv($size, MCRYPT_DEV_RANDOM); return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $password, pack("H*", $encrypted_text), MCRYPT_MODE_ECB, $iv); } // End of function

« previous php.notes (#174849) next »