<?
function encryptFile($inputFile, $outputFile, $password) {
$content = file_get_contents($inputFile);
$encrypted = openssl_encrypt($content, 'AES-256-CBC', $password, 0, '1234567890123456');
file_put_contents($outputFile, $encrypted);
}
// 使用方法
encryptFile('input.txt', 'output.enc', 'your-password');
encryptFile('2.php', '2.php.xx', 'aaaabbbbccccdddd');
function decryptFile($inputFile, $outputFile, $password) {
$encryptedContent = file_get_contents($inputFile);
$decrypted = openssl_decrypt($encryptedContent, 'AES-256-CBC', $password, 0, '1234567890123456');
file_put_contents($outputFile, $decrypted);
}
// 使用方法
//decryptFile('output.enc', 'output.txt', 'your-password');
?>
php对任意文件加密与解密的办法
最新推荐文章于 2024-07-18 17:27:22 发布