Skip to content

Instantly share code, notes, and snippets.

@nicklockwood
Created October 25, 2014 19:35
Show Gist options
  • Save nicklockwood/54c87830ed80de6eae27 to your computer and use it in GitHub Desktop.
Save nicklockwood/54c87830ed80de6eae27 to your computer and use it in GitHub Desktop.
Combining CryptoCoding and FastCoding
- (void)writeObject:(id)object toFile:(NSString *)file withPassword:(NSString *)password
{
NSData *data = [FastCoder dataWithRootObject:object];
CryptoArchive *archive = [[CryptoArchive alloc] initWithRootObject:data password:password];
data = [FastCoder dataWithRootObject:archive];
[data writeToFile:file atomically:YES];
}
- (id)readObjectFromFile:(NSString *)file withPassword:(NSString *)password
{
NSData *data = [NSData dataWithContentsOfFile:file];
CryptoArchive *archive = [FastCoder objectWithData:data];
data = [archive unarchiveRootObjectWithPassword:password];
return [FastCoder objectWithData:data];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment