Mcrypt_encrypt不起作用

时间:2013-10-31 21:27:49

标签: php mcrypt

我被告知加密是发送变量的最佳方式。所以我找到了一段代码,但我不会工作

$salt = 'test';
function simple_encrypt($text){ // line 9
    return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $salt, $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
} // line 11

function simple_decrypt($text){
    return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $salt, base64_decode($text), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)));
}

错误是:

Fatal error: Cannot redeclare simple_encrypt() (previously declared in /home/baspeters/domains/bas-peters.nl/public_html/Forum2/inc/settings.php:9) in /home/baspeters/domains/bas-peters.nl/public_html/Forum2/inc/settings.php on line 11 

1 个答案:

答案 0 :(得分:1)

你有simple_encrypt函数声明了两次。确保您没有包含同时定义了simple_encrypt的文件。