public static HexStringToByteArray ( string hex ) : byte[] | ||
hex | string | |
return | byte[] |
public static byte[] HexStringToByteArray(string hex)
{
if (hex.Length % 2 == 1)
throw new Exception("The binary key cannot have an odd number of digits");
byte[] arr = new byte[hex.Length >> 1];
for (int i = 0; i < hex.Length >> 1; ++i)
{
arr[i] = (byte)((GetHexVal(hex[i << 1]) << 4) + (GetHexVal(hex[(i << 1) + 1])));
}
return arr;
}
public WorkBlock(JObject obj) { midstate = Program.HexStringToByteArray(obj["midstate"].ToString()); data = Program.HexStringToByteArray(obj["data"].ToString()); hash1 = Program.HexStringToByteArray(obj["hash1"].ToString()); target = Program.HexStringToByteArray(obj["target"].ToString()); }