私は HMAC-SHA256 エンコーディングを行っています。試しましたが、解決策が見つかりませんでした。
#include <CommonCrypto/CommonHMAC.h>
- (NSString *)hmacWithKey:(NSString *)key andData:(NSString *)data
{
const char *cKey = [key cStringUsingEncoding:NSASCIIStringEncoding];
const char *cData = [data cStringUsingEncoding:NSASCIIStringEncoding];
unsigned char cHMAC[CC_SHA256_DIGEST_LENGTH];
///////////////////////////////////////////////////////////////
////but on below line of code i am getting EXC_BAD_ACCESS//////
///////////////////////////////////////////////////////////////
CCHmac(kCCHmacAlgSHA256, cKey, strlen(cKey), cData, strlen(cData), cHMAC);
//////////////////////////////////////////////
NSData *out = [NSData dataWithBytes:cHMAC length:CC_SHA256_DIGEST_LENGTH];
// description converts to hex but puts <> around it and spaces every 4 bytes
NSString *hash = [out description];
hash = [hash stringByReplacingOccurrencesOfString:@" " withString:@""];
hash = [hash stringByReplacingOccurrencesOfString:@"<" withString:@""];
hash = [hash stringByReplacingOccurrencesOfString:@">" withString:@""];
// hash is now a string with just the 40char hash value in it
NSLog(@"%@",hash);
return hash;
}
私がここで何をしているのか教えてください。ありがとう