So I\'m trying to figure out how to do a hmacshad256 hash on ios as that\'s the hash I did for the wcf service api I made. I\'ve been trying to look for some info about it but w
+ (NSString *)hmacSHA256EncryptString{
NSString * parameterSecret = @"input secret key";
NSString *plainString = @"input encrypt content string";
const char *secretKey = [parameterSecret cStringUsingEncoding:NSUTF8StringEncoding];
const char *plainData = [plainString cStringUsingEncoding:NSUTF8StringEncoding];
unsigned char cHMAC[CC_SHA256_DIGEST_LENGTH];
CCHmac(kCCHmacAlgSHA256, secretKey, strlen(secretKey), plainData, strlen(plainData), cHMAC);
NSData *HMACData = [NSData dataWithBytes:cHMAC length:sizeof(cHMAC)];
const unsigned char *bufferChar = (const unsigned char *)[HMACData bytes];
NSMutableString *hmacString = [NSMutableString stringWithCapacity:HMACData.length * 2];
for (int i = 0; i < HMACData.length; ++i){
[hmacString appendFormat:@"%02x", bufferChar[i]];
}
return hmacString;
}