要将目录的值存储在.txt
文件中,我使用以下加密方式:
$MainFolderName = 'uploads/folder1';
$key = "raf-key";
$encrypted = bin2hex(openssl_encrypt($MainFolderName,'AES-128-CBC', $key));
$decrypted = openssl_decrypt(hex2bin($encrypted),'AES-128-CBC',$key);
将加密后的$MainFolderName
的值存储在文件dir.txt
中:
$actualdir = fopen("dir.txt", "w") or die("Unable to open file!");
$encrypted = bin2hex(openssl_encrypt($MainFolderName,'AES-128-CBC', $key));
fwrite($actualdir, $encrypted);
fclose($actualdir);
如何使用dir.txt
从fread()
读取解密的值?
我已经有这个了:
// Read actual dir from file "dir.txt"
$readdir = fopen("dir.txt", "r") or die("Unable to open file!");
$dir = fread($readdir,filesize("dir.txt")); // read decrypted value and bind to var $dir
fclose($readdir);