Question

i want to generate HMAC-SHA1 of NSString type variable. I see the post but this method give me error in CCHmac(kCCHmacAlgSHA256, cKey, strlen(cKey), cData, strlen(cData), cHMAC);

and

NSString *hash = [HMAC base64Encoding]; line.

Please suggest how can I generate the HMAC-SHA1 of any string.

Was it helpful?

Solution

Have you got this at the top of your source file?

#import <CommonCrypto/CommonHMAC.h>

Regarding the base64 part of your question, this question will show you where to get a base64 encoding library/protocol.

OTHER TIPS

About the base64Encoding problem: This is because NSData does not contains this method by default, you need to extend NSData with that. In this link is explained http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html good luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top