Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nishabe/fbcdfeda7f3b4aed6585710602e730df to your computer and use it in GitHub Desktop.
Save nishabe/fbcdfeda7f3b4aed6585710602e730df to your computer and use it in GitHub Desktop.
OBJC: HMAC creation - Pass Key and Data as NSData
- (NSData *)generateHMACwith:(NSData *)key key:(NSData *)data {
NSMutableData *macOut = [NSMutableData dataWithLength:CC_SHA256_DIGEST_LENGTH];
CCHmac( kCCHmacAlgSHA256,
key.bytes,
key.length,
data.bytes,
data.length,
macOut.mutableBytes);
return macOut;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment