Created
September 4, 2014 07:50
-
-
Save djfumberger/9f766a09e06c07e17ca8 to your computer and use it in GitHub Desktop.
This file contains 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
- (NSString *)hashForObject:(NSObject*)object { | |
// Archive data | |
NSData *d = [NSKeyedArchiver archivedDataWithRootObject: object]; | |
// Create MD5 | |
unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH]; | |
CC_MD5(d.bytes, d.length, md5Buffer); | |
NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2]; | |
for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) | |
[output appendFormat:@"%02x",md5Buffer[i]]; | |
return output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment