1

由于密码学出口规定,可以使用这个库吗?或者我可以使用哪一个来压缩/解压缩文件?

4

2 回答 2

1

我不知道 SSZipArchive 是否允许在分布式应用程序中使用,但我使用的库是Objective-Zip

它可以很容易地集成到任何项目中。

压缩示例代码:

// 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];

解压示例代码:

// 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];
于 2013-03-05T23:53:04.893 回答
0

实际上,您可以在 iOS 应用程序中进行加密。您只需向 NSA 提交申请,您是谁以及应用程序中的加密类型。回复您的注册号通常会在 30 分钟内完成。它是自动或半自动的。他们只是收集有关开发人员的信息。

注册为 iOS 开发者更简单。

我的意见:-

如果您不在 ZIP 库中使用加密,那么您应该提交任何申请。链接器将在优化后删除该代码。没有使用该代码。但是,如果您使用 iOS 附带的加密,那么您应该申请。例如,如果 UIWebView 打开 https:// URL(例如 Facebook),但如果您使用 UIWebView 打开非安全页面,则不应申请。

于 2013-03-06T00:05:17.240 回答