ETH签名后 data数据转字符串

2019-03-22  本文已影响0人  item_小朋
image.png

data中有00和空格
+(NSString *)transformCharateristicValueFromData:(NSData *)dataValue{
if (!dataValue || [dataValue length] == 0) {
return @"";
}
NSMutableString *destStr = [[NSMutableString alloc]initWithCapacity:[dataValue length]];

[dataValue enumerateByteRangesUsingBlock:^(const void * _Nonnull bytes, NSRange byteRange, BOOL * _Nonnull stop) {
    unsigned char *dataBytes = (unsigned char *)bytes;
    for (int i = 0; i < byteRange.length; i++) {
        NSString *hexStr = [NSString stringWithFormat:@"%x",(dataBytes[i]) & 0xff];
        if ([hexStr length] == 2) {
            [destStr appendString:hexStr];
        }else{
            [destStr appendFormat:@"0%@",hexStr];
        }
    }
}];
return destStr;

}

上一篇下一篇

猜你喜欢

热点阅读