sharp-cryptonote-tool/tools/HexString.cs

21 lines
447 B
C#

using System;
namespace cryptonote.tools
{
public class HexString
{
public static byte[] toBytes(string hexstring)
{
byte[] bytes = new byte[hexstring.Length >> 1];
for (int n = 0; n < hexstring.Length >> 1;n++){
bytes[n] = Convert.ToByte(hexstring.Substring(n << 1, 2), 16);
}
return bytes;
}
public static String toString(byte[] bytes){
return BitConverter.ToString(bytes).Replace("-", String.Empty);
}
}
}