Created
October 25, 2014 19:35
-
-
Save nicklockwood/54c87830ed80de6eae27 to your computer and use it in GitHub Desktop.
Combining CryptoCoding and FastCoding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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