我正在制作一个页面,该页面将用于解密将从其他网站获得的.txt文件。我已经能够解密,但是只能以1比1解密,所以我尝试将1比1解密并将它们全部放入Winrar中。不幸的是,我遇到了与“ addFromString”方法有关的错误(帖子标题)。
<?php
$zip = new ZipArchive();
$res = $zip->open('test.zip', ZipArchive::CREATE);
$directory = 'uploadFiles/';
foreach (glob("uploadFiles/*.txt") as $file) {
$decrypted = decrypt_file($file,'pass');
$zip->addFromString($file, $decrypted);
}
if($res !== TRUE){
echo $res;
}
$zip->close();
function decrypt_file($file,$passphrase){
$iv = substr(md5("\x18\x3C\x58".$passphrase,true),0,8);
$key = substr(md5("\x2D\xFC\xD8".$passphrase,true).md5("\x2D\xFC\xD8".$passphrase,true),0,24);
$opts = array('iv'=>$iv, 'key'=>$key);
$fp = fopen($file,'rb');
stream_filter_append($fp, 'mdecrypt.tripledes', STREAM_FILTER_READ, $opts);
return $fp;
}
?>