i have a little problem: my decryption won t give me the same string i encoded, and i can t find the problem... looked in other posts, but nothing helpful there here are my functions:
public static function encryptData($data){
if($key = self::getEncryptionKey()){
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB,$iv));
} else {
return false;
}
}
public static function decryptData($data)
{
if($key = self::getEncryptionKey()){
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
return mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($data), MCRYPT_MODE_ECB,$iv);
} else {
return false;
}
}
问题在哪里? i 这里绝望......