Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Hash-based message authentication code Ref:
- (NSString*) HMACWithSecret:(NSString*)secret andData:(NSString *)data
CCHmacContext ctx;
const char *key = [secret UTF8String];
const char *str = [data UTF8String];
unsigned char mac[CC_SHA256_DIGEST_LENGTH];
char hexmac[CC_SHA256_DIGEST_LENGTH];
char *p;
CCHmacInit( &ctx, kCCHmacAlgSHA256, key, strlen( key ));
CCHmacUpdate( &ctx, str, strlen(str) );
CCHmacFinal( &ctx, mac );
p = hexmac;
for (int i = 0; i < CC_SHA256_DIGEST_LENGTH; i++ ) {
snprintf( p, 3, "%02x", mac[ i ] );
p += 2;
return [NSString stringWithUTF8String:hexmac];

This comment has been minimized.

Copy link
Owner Author

yangboz commented Nov 26, 2013

2013-11-26 17:16:07.704 ChatBotsMessager[547:60b] API request response str:{"success":0,"errorType":"Missing parameter","errorMessage":"The hash parameter must be passed in the url."}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.