note 9517 deleted from ref.mcrypt by derick

From: Date: Sun, 12 May 2002 15:34:10 +0000
Subject: note 9517 deleted from ref.mcrypt by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-30517@lists.php.net to get a copy of this message
Under libmcrypt 2.4.x it appears that text is encrypted to high ASCII which can be problematic for international users. Therefore to correct this problem, I have done the following (which encrypts text to hex vice-versa): DEFINE ("Keysize","f23r09aj09f3wqj90"); function enc($data) { $td = mcrypt_module_open (MCRYPT_TripleDES, "", MCRYPT_MODE_ECB, ""); $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND); $encdata = mcrypt_ecb (MCRYPT_TripleDES,(Keysize), $data, MCRYPT_ENCRYPT, $iv); $hextext=bin2hex($encdata); return $hextext; } function dec($data) { $td = mcrypt_module_open (MCRYPT_TripleDES, "", MCRYPT_MODE_ECB, ""); $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND); $dectext = mcrypt_ecb (MCRYPT_TripleDES,(Keysize), hex2bin($data), MCRYPT_DECRYPT,$iv); return $dectext; } function hex2bin($data) { $len = strlen($data); return pack("H" . $len, $data); } Regards, Avinesh

« previous php.notes (#30517) next »