I am making a page that will serve to decrypt .txt files that I will get from another website. I have been able to decrypt but only 1 to 1 so I am trying to decrypt 1 to 1 and put them all in a winrar. Unfortunately I'm having an error (post title) related to the "addFromString" method.
<?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;
}
?>
Aucun commentaire:
Enregistrer un commentaire