2019-10-09 17:10:16 +02:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-07-29 23:47:25 +02:00
|
|
|
using System;
|
|
|
|
using System.Globalization;
|
|
|
|
|
2019-09-17 18:07:15 +02:00
|
|
|
namespace MediaBrowser.Common
|
2019-07-29 23:47:25 +02:00
|
|
|
{
|
|
|
|
public static class HexHelper
|
|
|
|
{
|
|
|
|
public static byte[] FromHexString(string str)
|
|
|
|
{
|
|
|
|
byte[] bytes = new byte[str.Length / 2];
|
|
|
|
for (int i = 0; i < str.Length; i += 2)
|
|
|
|
{
|
|
|
|
bytes[i / 2] = byte.Parse(str.Substring(i, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
|
|
|
|
}
|
|
|
|
|
|
|
|
return bytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string ToHexString(byte[] bytes)
|
|
|
|
=> BitConverter.ToString(bytes).Replace("-", "");
|
|
|
|
}
|
|
|
|
}
|