加密的时候的需要开启openssl的扩展。
加密时候的参数选项
Aes加密需要的参数信息:
加密方式:CBC
填充:pkcs7padding
数据块:128
密码:1234567890123456
偏移量:abcdefghijklmnop
输出:base64
PHP实现加解密
public function encryptWithOpenssl($data = '')
{
return base64_encode(openssl_encrypt($data, "AES-128-CBC", '1234567890123456', OPENSSL_RAW_DATA, 'abcdefghijklmnop'));
}
public function decryptWithOpenssl($data = '')
{
return openssl_decrypt(base64_decode($data), "AES-128-CBC",'1234567890123456', OPENSSL_RAW_DATA, 'abcdefghijklmnop');
}