Open cytec opened 7 years ago
If the headers are encrypted, then sadly no. If they're not and only the files are encrypted, then you can use:
public function extractFile($filename, $destination=null, $password=null)
You'll need to configure an external unrar client for this, though, unless you want to try to implement the decryption in PHP ;-) There are some examples in the tests, starting here.
Thanks for the reply :)
Im mainly interested in public function getArchiveFileList($recurse=true, $all=false, $source=null)
to see what's inside the archive. already found the extractFiles
option, but if i get that correctly this only unrars the content and stores it inside a given folder...
Basically what i want to do is the equivalent of : unrar l -pPASS archive.rar
to get a list of all files contained inside the archive :)
Sure, I understand, but if the headers that contain the archive file list are also encrypted then basically all this script could do is wrap an exec of ... yes, you guessed it: unrar l -pPASS archive.rar
... and then there's little you can do with the result in PHP beyond simply listing it. There are other PHP scripts that already do that, but nobody's yet implemented RAR decryption in pure PHP, afaik.
I didn't implement that exec because the use case of encrypted headers is rare in the contexts in which this library is mostly used, and if you get to the point of needing it then you may as well just use a binary unrar anyway. That said, I could resurrect the dev environment and look at it again if there's any interest.
OR BETTER YET: someone else implement it and I'll accept their PR because I'm suuuuuper lazy. ;-)
Any chance to get Support for encrypted archives when i know the password? I have lots of encrypted rar files which i know the password for because i'm the one who encrypted those in the first place. Sadly im not able to use this library with those files...
EDIT: I'm thinking about something like
$archive->setPassword("xyZ");
which then get's used to extract the list of files for example...