/// <summary>
    /// byte[]流转十六进制字符串 0x34---->"34"
    /// </summary>
    /// <param name="bytes"></param>
    /// <returns></returns>
    public static string ToHexString(byte[] bytes)
    {
            static char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7','8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
        char[] chars = new char[bytes.Length * 2];
        for (int i = 0; i < bytes.Length; i++)
        {
            int b = bytes[i];//十六进制转化为十进制 0x34->52
            chars[i * 2] = hexDigits[b >> 4];
            chars[i * 2 + 1] = hexDigits[b & 0xF];
        }
        return new string(chars);
    }

 

相关文章:

  • 2021-09-25
  • 2022-12-23
  • 2022-01-09
  • 2021-12-01
  • 2021-10-01
猜你喜欢
  • 2022-12-23
  • 2022-02-22
  • 2022-01-27
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案