如何在PHP中使用MCRYPT用IV编码AES128?

时间:2013-09-13 19:26:03

标签: php mcrypt

这是我得到的:

$username = "username";
$password = "password";
$companyID = "companyID";

function encodeAES($u, $p, $c){
    $original = "$u,$p,$c";
    $key = "myKey";
    $IV = "00000000";
    return rtrim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $original, MCRYPT_MODE_CBC, $IV)), "\0\3");
}

print encodeAES($username, $password, $companyID);

错误是:

Fatal error: Call to undefined function mcrypt_encrypt() on line 9

1 个答案:

答案 0 :(得分:2)

我遇到了与PHP 5.2.10相同的问题,打开php.ini并通过删除;允许php_mycrypt.dll扩展,即更改:

;extension=php_mcrypt.dll to extension=php_mcrypt.dll