Heim >Backend-Entwicklung >PHP-Tutorial >php-mcrypt 在PHP5.60+的版本中怎么使用?

php-mcrypt 在PHP5.60+的版本中怎么使用?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-02 11:32:591372Durchsuche

php

目前项目中的一个密码对接放在正式环境之后出现了问题,
原因是在PHP5.6以上的版本中修改了mcrypt_encrypt 和 mcrypt_decrypt,
有人知道在新版本的PHP中应该怎么使用这两个方法吗?

<code>protected function encrypt($string) {        //加密用的密钥文件         $key = md5("xxxxxxxx");        //加密方法         $cipher_alg = MCRYPT_TRIPLEDES;        //初始化向量来增加安全性         $iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher_alg,MCRYPT_MODE_ECB), MCRYPT_RAND);         //开始加密         $encrypted_string = mcrypt_encrypt($cipher_alg, $key, $string, MCRYPT_MODE_ECB, $iv);        var_dump($encrypted_string);        return base64_encode($encrypted_string);//转化成16进制    }protected function decrypt($string) {        $string = base64_decode($string);        //加密用的密钥文件         $key = md5("xxxxxxxx");        //加密方法         $cipher_alg = MCRYPT_TRIPLEDES;        //初始化向量来增加安全性         $iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher_alg,MCRYPT_MODE_ECB), MCRYPT_RAND);         //开始解密         $decrypted_string = mcrypt_decrypt($cipher_alg, $key, $string, MCRYPT_MODE_ECB, $iv);         return $decrypted_string;    }</code>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn