byte[] buf
buf.ToHexString("T");
public static string ToHexString(this byte[] bytes, string format = "")
{
if (bytes == null) return "";
switch (format)
{
case "s":
return string.Join(" ", bytes.Select(i => i.ToString("x2")).ToArray());
case "S":
return string.Join(" ", bytes.Select(i => i.ToString("X2")).ToArray());
case "T":
return string.Join("", bytes.Select(i => i.ToString("X2")).ToArray());
case "t":
default:
return string.Join("", bytes.Select(i => i.ToString("x2")).ToArray());
}
}
字节数组转换成十六进制字符串
最新推荐文章于 2024-06-28 01:36:16 发布