private byte[] GetBytesFromHexString(string hexString) { // we must have an even number of characters if (hexString.Length % 2 != 0) { return null; } byte[] buffer = new byte[hexString.Length / 2]; for (int x = 0; x < hexString.Length; x++) { string singleByteSection = hexString.Substring(x, 2); buffer[x / 2] = Convert.ToByte(singleByteSection, 16); x++; } return buffer; }