// 定义加密算法和密钥
$method = 'AES-128-CBC';
$key = 'xxx';

// 待加密的数据
$data = time();

// 加密
$iv = openssl_random_pseudo_bytes(16);
$cipherText = openssl_encrypt($data, $method, $key, OPENSSL_RAW_DATA, $iv);
$cipherText = base64_encode($cipherText);
var_dump($cipherText);
// 解密
$bb = base64_decode($cipherText);
$decryptedText = openssl_decrypt($bb, $method, $key, OPENSSL_RAW_DATA, $iv);

// 输出结果
// echo 'Original text: '.$data."\n";
// echo 'Encrypted text: '.$cipherText."\n";
echo 'Decrypted text: '.$decryptedText."\n";