public static byte[] StrToByte(string strValue)
{
int length = strValue.Length;
byte[] buffer = new byte[length / 2];
if ((length % 2) == 0)
{
for (int i = 0; i < (length / 2); i++)
{
buffer[i] = Convert.ToByte(strValue.Substring(i * 2, 2), 0x10);
}
}
return buffer;
}
|