rarinfo icon indicating copy to clipboard operation
rarinfo copied to clipboard

support for encrypted archives?

Open cytec opened this issue 6 years ago • 3 comments

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...

cytec avatar Oct 13 '17 09:10 cytec

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.

zeebinz avatar Oct 13 '17 17:10 zeebinz

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 :)

cytec avatar Oct 16 '17 09:10 cytec

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. ;-)

zeebinz avatar Oct 16 '17 19:10 zeebinz