Due to cryptography export regulations, it is possible to use this library? or which one could I use to compress/decompress files?
-
1Are you asking about using password protected zip files or do you really just need a plain old zip/unzip library? – rmaddy Mar 06 '13 at 00:00
-
Sorry if I wasn't clear, I just want to zip/unzip, don't need/want encryption at all – aprunedamtz Mar 06 '13 at 22:18
-
Try Objective-Zip, ZipKit, or plain old minizip. – rmaddy Mar 06 '13 at 22:45
-
minizip comes with a file named "crypt.h" I'm not an expert, is this not cryptography? Would it be safe to include it and submit to App Store. Another possibility is just remove that file, I think – aprunedamtz Mar 07 '13 at 16:45
-
If your app doesn't use any encryption then there is nothing to worry about. It doesn't matter if one of the libraries happens to support encryption. The import issue is whether your app uses encryption or not. – rmaddy Mar 07 '13 at 16:47
2 Answers
I don't know if SSZipArchive is allowed to use in distributed apps, but the library I am using is Objective-Zip.
It can be easily integrated into any project.
Sample code for zipping:
// create a zip file for writing
ZipFile *zipFile= [[ZipFile alloc] initWithFileName:pathOfTheFileToBeZipped mode:ZipFileModeCreate];
// Add a file, write to its stream and close it
ZipWriteStream *stream1= [zipFile writeFileInZipWithName:@"abc.txt" fileDate:[NSDate dateWithTimeIntervalSinceNow:-86400.0] compressionLevel:ZipCompressionLevelBest];
NSString *text= @"abc";
[stream1 writeData:[text dataUsingEncoding:NSUTF8StringEncoding]];
[stream1 finishedWriting];
// Add another file, write to its stream and close it
ZipWriteStream *stream2= [zipFile writeFileInZipWithName:@"x/y/z/xyz.txt" compressionLevel:ZipCompressionLevelNone];
NSString *text2= @"XYZ";
[stream2 writeData:[text2 dataUsingEncoding:NSUTF8StringEncoding]];
[stream2 finishedWriting];
// Close the zip file
[zipFile close];
Sample code for unzipping:
// open the zip file for reading
ZipFile *unzipFile = [[ZipFile alloc] initWithFileName:pathOfTheFileToBeUnzipped mode:ZipFileModeUnzip];
// retrieve the info of the files inside
NSArray *infos= [unzipFile listFileInZipInfos];
// iterate over files
for (FileInZipInfo *info in infos) {
// locate the file in the zip
[unzipFile locateFileInZip:info.name];
// expand the file in memory
ZipReadStream *read= [unzipFile readCurrentFileInZip];
NSData *data = [read readDataOfLength:info.length];
[read finishedReading];
// construct the folder/file path structure
NSString *unzipPathFilename = [unzipPath stringByAppendingPathComponent:info.name];
NSString *unzipPathFoldername = [[unzipPathFilename stringByDeletingLastPathComponent] copy];
NSError *errorw;
// write the unzipped files, with some consistency checks
NSRange range = [unzipPathFoldername rangeOfString:@"__MACOSX"];
if (range.location == NSNotFound) {
if ([fileManager createDirectoryAtPath:unzipPathFoldername withIntermediateDirectories:YES attributes:nil error:&errorw]) {
if (![[unzipPathFilename pathExtension] isEqualToString:@""] && ![[[unzipPathFilename lastPathComponent] substringToIndex:1] isEqualToString:@"." ]) {
[data writeToFile:unzipPathFilename atomically:NO];
}
}
else {
NSLog(@"Directory Fail: %@", errorw);
}
}
}
// close the zip file
[unzipFile close];

- 809
- 6
- 23
-
The second part of is his question is asking which library he should use for zipping/unzipping. He does not strictly state that he needs encryption, instead he asks if it is allowed to use SSZipArchive, which uses encryption, and that is I don't know. – tolgamorf Mar 05 '13 at 23:58
-
I don't want/need encryption, this library Objective - Zip uses encryption? Thanks for your answer – aprunedamtz Mar 06 '13 at 22:23
-
No, it does not use encryption. But, you can password protect your zip files if desired. – tolgamorf Mar 07 '13 at 01:21
Actually you are allowed to have encryption in iOS application. You just have to submit application to NSA who you are and what kind of encryption do have in app. Respond with your reg number usually comes in 30 minutes. It is automatic or semi-automatic. They just collect information about developers.
It is simpler then register as iOS developer.
My opinion:-
If you do not use encryption in ZIP library then you should submit any application. Linker will remove that code after optimization. That code is not used. But if you use encryption even that comes with iOS then you should apply. e.g. UIWebView if it opens https:// URLs (e.g. Facebook) but if you use UIWebView to open non secure pages then you should not apply.

- 6,286
- 5
- 44
- 86