美文网首页
ETH签名后 data数据转字符串

ETH签名后 data数据转字符串

作者: item_小朋 | 来源:发表于2019-03-22 08:50 被阅读0次
    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;
    

    }

    相关文章

      网友评论

          本文标题:ETH签名后 data数据转字符串

          本文链接:https://www.haomeiwen.com/subject/nqikvqtx.html