Created
May 2, 2012 17:45
-
-
Save kristopherjohnson/2578620 to your computer and use it in GitHub Desktop.
Generate SHA1 hash from UTF8 encoding of a string
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
- (NSData *)SHA1HashOfUTF8String { | |
const char *UTF8 = [self UTF8String]; | |
size_t UTF8Length = strlen(UTF8); | |
unsigned char hashedUTF8[CC_SHA1_DIGEST_LENGTH]; | |
CC_SHA1(UTF8, UTF8Length, hashedUTF8); | |
return [NSData dataWithBytes:hashedUTF8 length:sizeof(hashedUTF8)]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment