aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Extensions/HexHelper.cs
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2019-07-29 23:47:25 +0200
committerBond_009 <bond.009@outlook.com>2019-08-11 15:54:58 +0200
commit5eaf5465a55df0359f85077b7922ca4a45681831 (patch)
tree73b87fef4f2b7e857bdd4177d7fdce3fe79aaaeb /MediaBrowser.Common/Extensions/HexHelper.cs
parent1ad67e223f581efd417efa2bb1cb626c50a6f5a9 (diff)
Check checksum for plugin downloads
* Compare the MD5 checksum when downloading plugins * Reduced log spam due to http requests * Removed 'GetTempFileResponse' function from HttpClientManager * Fixed caching for HttpClientManager
Diffstat (limited to 'MediaBrowser.Common/Extensions/HexHelper.cs')
-rw-r--r--MediaBrowser.Common/Extensions/HexHelper.cs22
1 files changed, 22 insertions, 0 deletions
diff --git a/MediaBrowser.Common/Extensions/HexHelper.cs b/MediaBrowser.Common/Extensions/HexHelper.cs
new file mode 100644
index 000000000..3d80d94ac
--- /dev/null
+++ b/MediaBrowser.Common/Extensions/HexHelper.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Globalization;
+
+namespace MediaBrowser.Common.Extensions
+{
+ 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("-", "");
+ }
+}