在php中使用mcrypt_create_iv

时间:2014-01-09 21:04:55

标签: php mysql fatal-error mcrypt

好的,我正在解决这个错误

Fatal error: Call to undefined function mcrypt_create_iv() in ..... on line 8

现在我做了一些阅读,发现我需要安装或更新我的php,问题是我不使用我的大学服务器而且无法更新它,至少我认为我不能。

有没有一个简单的方法。

Hash.php

    <?php
class Hash {
    public static function make($string, $salt = '') {
        return hash('sha256', $string . $salt);
    }

    public static function salt($length) {
        return mcrypt_create_iv($length);
    }

    public static function unique() {
        return self::make(uniqid());
    }
}

1 个答案:

答案 0 :(得分:0)

您需要安装mcrypt。 如果使用基于Debian的Linux系统,则可以运行以下命令:

sudo apt-get install php5-mcrypt
sudo /etc/init.d/apache2 restart