字符串转16进制
-(NSString*)str2HexStr:(NSString*)str{
NSString* hexStr= @"";
NSString* hex = @"0123456789ABCDEF";
NSString* str4Up = [str uppercaseString];
// 补绝对0 0x00 而非字符‘0’ 所以要先转16进制补0,再转回
for (int i =0 ; i<[str4Up length]; i++) {
char dd = [str4Up characterAtIndex:i];
hexStr = [NSString stringWithFormat:@"%@%c%c",hexStr,[hex characterAtIndex:(dd & 0x0f0)>>4],[hex characterAtIndex:dd&0x0f]];
}
return hexStr;
}