Created
October 20, 2014 16:28
-
-
Save osdouglas/5d943a30c8794ac20fb8 to your computer and use it in GitHub Desktop.
SHA1 in ObjC
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
#include <CommonCrypto/CommonDigest.h> | |
unsigned char digest[CC_SHA1_DIGEST_LENGTH]; | |
NSData *stringBytes = [someString dataUsingEncoding: NSUTF8StringEncoding]; /* or some other encoding */ | |
if (CC_SHA1([stringBytes bytes], [stringBytes length], digest)) { | |
/* SHA-1 hash has been calculated and stored in 'digest'. */ | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment