<?php
// 待加密内容
$content = "hello world";
//关键字
$key = '1234567812345678';
//向量
$iv = substr(md5(uniqid(rand())), -16);
echo "使用 openssl(推荐):" . PHP_EOL;
echo 'openssl 加密:' . PHP_EOL;
$data = openssl_encrypt($content, "AES-128-CBC", $key, 0, $iv);
var_dump($data);
echo 'openssl 解密:' . PHP_EOL;
$data = openssl_decrypt($data, "AES-128-CBC", $key, 0, $iv);
var_dump($data);