public static byte[] ConvertHexString(string hex)
{
if (!hex.StartsWith("0x"))
BfsCompiler.ReportError("Could not convert hex string to byte array!");
hex = hex.Substring(2);
int numberChars = hex.Length;
byte[] bytes = new byte[numberChars / 2];
for (int i = 0; i < numberChars; i += 2)
bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
return bytes;
}