forked from DNAProject/DNA
-
Notifications
You must be signed in to change notification settings - Fork 1
byte数组转hex string
tanyuan edited this page Aug 4, 2017
·
1 revision
using Neo.SmartContract.Framework;
using Neo.SmartContract.Framework.Services.Neo;
class A : FunctionCode
{
public static string Main()
{
byte[] input = {0x5c,0x63,0x2b,0x9d,0xfe,0x78,0x8a,0x7f,0x88,0x1a,0x33,0xc3,0xcc,0xa3,0x14,0x38,0x86,0x10,0xb6,0x6f};
string str= BytesToHexStr(input);
return str;
}
public static string BytesToHexStr(byte[] bys)
{
int highByte, lowByte;
string str = "";
for (int i = 0; i < bys.Length; i++)
{
highByte = bys[i] >> 4;
lowByte = bys[i] & 0x0f;
highByte += 0x30;
if (highByte > 0x39)
{
int var = highByte + 0x27;
str = str + var;
}
else
str = str + highByte;
lowByte += 0x30;
if (lowByte > 0x39)
{
int val = lowByte + 0x27;
str = str + val;
}
else
str = str + lowByte;
}
return str;
}
}
执行码:52C56B145C632B9DFE788A7F881A33C3CCA314388610B66F6C766B00527AC46C766B00C3616513006C766B51527AC46C766B51C3616C756657C56B6C766B00527AC4006C766B53527AC4006C766B54527AC462DB006C766B00C36C766B54C3517F54996C766B51527AC46C766B00C36C766B54C3517F5F846C766B52527AC46C766B51C30130936C766B51527AC46C766B51C30139A16327006C766B51C30127936C766B55527AC46C766B53C36C766B55C37E6C766B53527AC46215006C766B53C36C766B51C37E6C766B53527AC46C766B52C30130936C766B52527AC46C766B52C30139A16327006C766B52C30127936C766B56527AC46C766B53C36C766B56C37E6C766B53527AC46215006C766B53C36C766B52C37E6C766B53527AC46C766B54C351936C766B54527AC46C766B54C36C766B00C3C09F631CFF6C766B53C3616C7566
输入参数:空
执行结果:5c632b9dfe788a7f881a33c3cca314388610b66f