Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password setter method for SevenZipFile object and/or password argument for extract/read #618

Open
boulwabd opened this issue Sep 23, 2024 · 1 comment
Labels
question Further information is requested

Comments

@boulwabd
Copy link

boulwabd commented Sep 23, 2024

It is probably not a very common use case but I frequently work with 7z files that I need to try several passwords for or set a password after I have already initialized the object. Setting the password after initializing the SevenZipFile object currently requires updating the password for all the Folder objects within the ArchiveFile objects of each archive member.

It would be nice to have a setpassword function similar to the ZipFile library and/or accept a password argument for the extract and read methods.

EDIT: Well apparently there is some kind of _lzma.LZMAError: Internal error in the decompression when you attempt to read or extract after trying with an incorrect password already. I'm guessing something to do with a file pointer somewhere so maybe it is just easier to instantiate a new object regardless.

@miurahr
Copy link
Owner

miurahr commented Sep 26, 2024

@boulwabd you can find a detailed specification of 7zip file format at https://py7zr.readthedocs.io/en/latest/archive_format.html

7zip format allow, and usually does, compressing header block in 7zip compressing format, and the 7zip compressing format can also be encrypted.
When py7zr reading header, which is just after checking signature header, that is a timing a creating object, it requires password if the archive is encrypted.

If you want rewind everythings before reading header, it is almost as same as creating new object.

@miurahr miurahr added the question Further information is requested label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants