修复一些小问题

This commit is contained in:
技术老胡
2024-11-11 15:58:19 +08:00
parent cd38b4cc04
commit 4b5e8bb763
7 changed files with 23 additions and 12 deletions

View File

@@ -1,3 +1,14 @@
<?php
echo '测试用例';
function encrypt($string, $key) {
$method = "AES-256-CBC";
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($method));
$encrypted = openssl_encrypt($string, $method, $key, 0, $iv);
// 将iv和加密字符串拼接起来
return base64_encode($iv . $encrypted);
}
$key = "your-encryption-key"; // 这里应该是一个安全的密钥
$string = "Hello, World!";
$encryptedString = encrypt($string, $key);
echo $encryptedString; // 输出加密字符串