<?php $key = "miyao";//密钥 $string="jiami";//需要加密的字符 $d = new d(); //加密 $crypttext = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key)))); $encrypted =trim($d->safe_b64encode($crypttext));//对特殊字符进行处理 echo $encrypted; // 解密 $key="miyao"; $crypttexttb=$d->safe_b64decode($encrypted);//对特殊字符解析 $decryptedtb = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($crypttexttb), MCRYPT_MODE_CBC, md5(md5($key))), "