Skip to content

Instantly share code, notes, and snippets.

@osdouglas
Created October 20, 2014 16:28
Show Gist options
  • Save osdouglas/5d943a30c8794ac20fb8 to your computer and use it in GitHub Desktop.
Save osdouglas/5d943a30c8794ac20fb8 to your computer and use it in GitHub Desktop.
SHA1 in ObjC
#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