懒得勤快 4 years ago
parent
commit
8f51c1b0e4

+ 1 - 0
Masuit.Tools.Abstractions/Net/PartialDownloader.cs

@@ -33,6 +33,7 @@ namespace Masuit.Tools.Net
         int _counter;
         private int _to;
         private int _totalBytesRead;
+        private bool _wait;
 
         /// <summary>
         /// 下载已停止

+ 6 - 33
Masuit.Tools.Abstractions/Security/RsaPem.cs

@@ -121,9 +121,7 @@ namespace Masuit.Tools.Security
                 BigInteger q = n / p;
                 if (p.CompareTo(q) > 0)
                 {
-                    BigInteger t = p;
-                    p = q;
-                    q = t;
+                    (p, q) = (q, p);
                 }
 
                 BigInteger exp1 = d % (p - BigInteger.One);
@@ -325,7 +323,7 @@ namespace Masuit.Tools.Security
                 return val;
             };
             //比较data从idx位置开始是否是byts内容
-            Func<byte[], bool> eq = (byts) =>
+            Func<byte[], bool> eq = byts =>
             {
                 for (var i = 0; i < byts.Length; i++, idx++)
                 {
@@ -423,29 +421,9 @@ namespace Masuit.Tools.Security
 
         private static readonly Regex PemCode = new Regex(@"--+.+?--+|\s+");
 
-        private static readonly byte[] SeqOid = {
-            0x30,
-            0x0D,
-            0x06,
-            0x09,
-            0x2A,
-            0x86,
-            0x48,
-            0x86,
-            0xF7,
-            0x0D,
-            0x01,
-            0x01,
-            0x01,
-            0x05,
-            0x00
-        };
-
-        private static readonly byte[] Ver = {
-            0x02,
-            0x01,
-            0x00
-        };
+        private static readonly byte[] SeqOid = { 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00 };
+
+        private static readonly byte[] Ver = { 0x02, 0x01, 0x00 };
 
 
         /// <summary>
@@ -701,12 +679,7 @@ namespace Masuit.Tools.Security
             str.Append("<RSAKeyValue>");
             str.Append("<Modulus>" + Convert.ToBase64String(KeyModulus) + "</Modulus>");
             str.Append("<Exponent>" + Convert.ToBase64String(KeyExponent) + "</Exponent>");
-            if (KeyD == null || convertToPublic)
-            {
-                /****生成公钥****/
-                //NOOP
-            }
-            else
+            if (KeyD != null && !convertToPublic)
             {
                 /****生成私钥****/
                 str.Append("<P>" + Convert.ToBase64String(ValP) + "</P>");