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

Add support for AES compression #110

Open
SravanPeddi opened this issue Jun 16, 2022 · 7 comments
Open

Add support for AES compression #110

SravanPeddi opened this issue Jun 16, 2022 · 7 comments
Assignees

Comments

@SravanPeddi
Copy link

SravanPeddi commented Jun 16, 2022

Hi Team,

I want to read one file from zip(which has password) folder without unzip/exract it. I am using following snippet.

UZKArchive *archive = [[UZKArchive alloc] initWithPath:zipPath password:@"49445" error:&archiveError];
NSError *error = nil;
NSArray<NSString*> *filesInArchive = [archive listFilenames:&error];
NSLog(@"filesInArchive %@",filesInArchive);
for(UZKFileInfo *info in [archive listFileInfo:&error])
{
    NSLog(@"file name %@ Compressed size %lld UnCompressed size %lld",info.filename,info.compressedSize,info.uncompressedSize);
}

I have a file in zip folder named "complete_49445_ak_pc_6922/49445.json"

NSData *extractedData = [archive extractDataFromFile:@"complete_49445_ak_pc_6922/49445.json" error:&error];

here i extracted data is coming as null.

i would like to read one file content based on that file content i would like to extract files.
How can we do that ?

i am able to get contents if zip is not having password. But I am facing issue if zip is having password only, though i have provided password for archive object.

Thanks,
Sravan

@abbeycode
Copy link
Owner

If extractedData is coming out null, then error should be populated with an NSError object describing what's going wrong. Can you tell me what it says if you print it?

@abbeycode
Copy link
Owner

I'm still curious to see what is in the NSError, but I also have some unit tests that deal with passwords, which may help you figure out what's going wrong. I've linked to a couple of examples below.

https://github.com/abbeycode/UnzipKit/blob/master/Tests/PasswordProtectionTests.m
https://github.com/abbeycode/UnzipKit/blob/master/Tests/ExtractFilesTests.m#L38

@SravanPeddi
Copy link
Author

SravanPeddi commented Jun 17, 2022

I am getting following error

Error Domain=UZKErrorDomain Code=-103 "Bad zip file" UserInfo={NSLocalizedFailureReason=Bad zip file, NSLocalizedRecoverySuggestion=Error opening archive (-103), NSURL=file:///Users/sravanpeddi/Library/Developer/CoreSimulator/Devices/B8E1609D-21D9-4C9A-8FF7-01AE9FB49AC6/data/Containers/Bundle/Application/06C48480-CFBB-4E43-BB9A-B721313B384D/SampleUnZip.app/complete_49445_ak_pc_6922.zip, NSLocalizedDescription=Bad zip file}

:: i am able to extract zip folder with given password in mac.

@abbeycode
Copy link
Owner

You're able to extract it using Archive Utility? Are you able to send me the file and password privately, so I can take a look? You can DM me on Twitter: @bbeyCode.

@SravanPeddi
Copy link
Author

SravanPeddi commented Jun 17, 2022

SampleUnZip.zip
Yes. i have attached sample project which has zip file. And password is 49467.

@abbeycode
Copy link
Owner

I was able to reproduce with the archive you included in your project, successfully unarchiving with other apps, and seeing the error you did with UnzipKit. I'm not yet sure what's going on, but will take a look.

@abbeycode abbeycode added bug and removed question labels Jun 24, 2022
@abbeycode abbeycode changed the title Reading files in zip folder without unzip Add support for AES compression Jun 24, 2022
@abbeycode abbeycode added enhancement and removed bug labels Jun 24, 2022
abbeycode added a commit that referenced this issue Jun 24, 2022
…ing AES encryption, and updated it to use a new error code reporting what went wrong (Issue #110)
abbeycode added a commit that referenced this issue Jun 24, 2022
…ing AES encryption, and updated it to use a new error code reporting what went wrong (Issue #110)
@abbeycode
Copy link
Owner

What's causing your issue is that the archive you sent is using the AES compression method, which isn't supported yet. I've updated your issue to turn it into a feature request for supporting this compression method. In the meantime, I'm adding to the v2.0 branch a new error code (UZKErrorCodeAES) for this case, so at least it's not mysterious (once my PR passes validation).

abbeycode added a commit that referenced this issue Jun 25, 2022
… 13) (#113)

* Added new error code (`UZKErrorCodeAES`) to report when an archive is AES-encrypted, since that compression method is not supported at this time (and otherwise the error doesn't help you arrive at that conclusion), as described in Issue #110 
* Upgraded project to Xcode 13-compatibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants