php写的AES加密解密类分享
(编辑:jimmy 日期: 2024/11/20 浏览:3 次 )
今天写了一个php的AES加密类。适用于Yii的扩展。
如果不用在Yii框架中,把代码中Yii::app()->params['encryptKey'] 换成你对应的默认key就可以了。
类代码:
<"\0"); } /** * Returns the length of the given string. * If available uses the multibyte string function mb_strlen. * @param string $string the string being measured for length * @return integer the length of the string */ private static function strlen($string) { return extension_loaded('mbstring') ? mb_strlen($string,'8bit') : strlen($string); } /** * Returns the portion of string specified by the start and length parameters. * If available uses the multibyte string function mb_substr * @param string $string the input string. Must be one character or longer. * @param integer $start the starting position * @param integer $length the desired portion length * @return string the extracted part of string, or FALSE on failure or an empty string. */ private static function substr($string,$start,$length) { return extension_loaded('mbstring') ? mb_substr($string,$start,$length,'8bit') : substr($string,$start,$length); } }
下一篇:PHP提交表单失败后如何保留已经填写的信息