Exemple #1
0
 /// <summary>
 /// 16进制 To 二进制
 /// </summary>
 /// <param name="data">字符串</param>
 /// <returns>byte[]数据</returns>
 public static byte[] HexToBinary(string data)
 {
     if ((data == null) || ((data.Length % 2) != 0))
     {
         return(null);
     }
     byte[] buffer = new byte[data.Length / 2];
     for (int i = 0; i < buffer.Length; i++)
     {
         int num2 = CharUtil.HexToInt(data[2 * i]);
         int num3 = CharUtil.HexToInt(data[(2 * i) + 1]);
         if ((num2 == -1) || (num3 == -1))
         {
             return(null);
         }
         buffer[i] = (byte)((num2 << 4) | num3);
     }
     return(buffer);
 }