You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
594 B
23 lines
594 B
5 years ago
|
using System;
|
||
|
using System.Globalization;
|
||
|
|
||
5 years ago
|
namespace MediaBrowser.Common
|
||
5 years ago
|
{
|
||
|
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("-", "");
|
||
|
}
|
||
|
}
|