每次我尝试运行 m_decrypt 时,都会抛出以下错误:
Warning: mcrypt_get_key_size(): Module initialization failed in /var/www/milo/system/encryption/common.php on line 51 Warning: mcrypt_get_block_size(): Module initialization failed in /var/www/milo/system/encryption/common.php on line 54 Warning: mcrypt_decrypt(): Module initialization failed in /var/www/milo/system/encryption/common.php on line 55
以下是驱动这一切的代码:
class encrpt
{
protected $data;
protected $key = "JUST A KEY";
protected $cipher = "MCRYPT_SERPENT_256";
protected $mode = "MCRYPT_MODE_CBC";
public function m_encrypt($data)
{
return (string)
base64_encode(
mcrypt_encrypt(
$this->cipher,
substr(md5($this->key),0,mcrypt_get_key_size($this->cipher, $this->mode)),
$data,
$this->mode,
substr(md5($this->key),0,mcrypt_get_block_size($this->cipher, $this->mode))
)
);
}
public function m_decrypt($data)
{
return (string)
mcrypt_decrypt(
$this->cipher,
substr(md5($this->key),0,mcrypt_get_key_size($this->cipher, $this->mode)),
base64_decode($data),
$this->mode,
substr(md5($this->key),0,mcrypt_get_block_size($this->cipher, $this->mode))
);
}
}
我不知道我错过了什么。我的 php-mcrypt 模块是否损坏或缺少依赖项?我在 PHP 5.3 上运行