PHP7利用openssl实现AES加密解密

作者:

在

<?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;

 

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注