<?php /** * PHP AES加密解密. * @author 春风 QQ 860646000 */ $key = 'woaichunfengboke'; //key $iv = '0123456789101112'; //iv $txt = '春风博客 网址:http://Chunblog.com/ 欢迎您!'; //字符串 /** *加密 **/ $string_e = base64_encode(openssl_encrypt($txt, 'AES-128-CBC', $key, true, $iv)); /** *解密 **/ $string_d = openssl_decrypt(base64_decode($string_e), 'AES-128-CBC',$key, true,$iv); echo '原字符串:',$txt; echo "<hr>\n"; echo '加密后字符串:',$string_e; echo "<hr>\n"; echo '解密后字符串:',$string_d;