aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/HexHelper.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Common/HexHelper.cs')
-rw-r--r--MediaBrowser.Common/HexHelper.cs22
1 files changed, 22 insertions, 0 deletions
diff --git a/MediaBrowser.Common/HexHelper.cs b/MediaBrowser.Common/HexHelper.cs
new file mode 100644
index 000000000..5587c03fd
--- /dev/null
+++ b/MediaBrowser.Common/HexHelper.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Globalization;
+
+namespace MediaBrowser.Common
+{
+ 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("-", "");
+ }
+}