|
|
@ -165,7 +165,7 @@ namespace Apewer |
|
|
|
|
|
|
|
#region Text
|
|
|
|
|
|
|
|
/// <summary>将字节数组转换为十六进制文本。</summary>
|
|
|
|
/// <summary>将字节数组转换为十六进制文本(小写)。</summary>
|
|
|
|
public static string ToHex(this byte[] bytes) |
|
|
|
{ |
|
|
|
int length = bytes.Length; |
|
|
@ -185,6 +185,9 @@ namespace Apewer |
|
|
|
/// <summary>将十六进制文本转换为字节数组。</summary>
|
|
|
|
public static byte[] FromHex(this string hex) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(hex)) return Empty; |
|
|
|
hex = hex.Replace(" ", "").Replace("-", ""); |
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(hex) || hex.Length < 2) return Empty; |
|
|
|
if (hex.Length % 2 != 0) return Empty; |
|
|
|
|
|
|
|