PHP 加密 解密
阿新 • • 發佈:2019-02-11
//加密
public static function encrypt($code){
return urlencode(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5("key"), $code, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));}
/**
* 解密
* @param [type] $code [description]
* @return [type] [description]
*/
public static function decrypt($code){
return urldecode(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5("key"), base64_decode($code), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)));
}