objective c SHA256 암호화
#import <CommonCrypto/CommonHMAC.h>
-(NSString*) sha256{
NSString* home = [@"~" stringByExpandingTildeInPath];
// NSLog(@"home===============%@",home);
NSString *mergePdfPath= [NSString stringWithFormat:@"%@/Documents/C0105.pdf",home];
// const char *s = [data cStringUsingEncoding:NSASCIIStringEncoding];
// NSData *keyData=[NSData dataWithBytes:s length:strlen(s)];
NSData *data = [[[NSData alloc] initWithContentsOfFile:mergePdfPath] autorelease];
uint8_t digest[CC_SHA256_DIGEST_LENGTH]={0};
CC_SHA256(data.bytes, data.length, digest);
NSData *out = [NSData dataWithBytes:digest length:CC_SHA256_DIGEST_LENGTH];
NSString *hash=[out description];
hash = [hash stringByReplacingOccurrencesOfString:@" " withString:@""];
hash = [hash stringByReplacingOccurrencesOfString:@"<" withString:@""];
hash = [hash stringByReplacingOccurrencesOfString:@">" withString:@""];
NSLog(@"hash====================%@",hash);
// NSLog(@"ha len ============%d",[hash length]);
return hash;
}
출처 : http://blog.naver.com/clubbboy?Redirect=Log&logNo=157383561