Browse Source

访问权限

懒得勤快 5 years ago
parent
commit
0953c0356c
2 changed files with 7 additions and 3 deletions
  1. 2 2
      Masuit.Tools/Security/RSACrypt.cs
  2. 5 1
      NetCoreTest/Program.cs

+ 2 - 2
Masuit.Tools/Security/RSACrypt.cs

@@ -13,12 +13,12 @@ namespace Masuit.Tools.Security
         /// <summary>
         /// 公钥
         /// </summary>
-        public string PublicKey;
+        public string PublicKey { get; protected internal set; }
 
         /// <summary>
         /// 私钥
         /// </summary>
-        public string PrivateKey;
+        public string PrivateKey { get; protected internal set; }
     }
 
     public enum RsaKeyType

+ 5 - 1
NetCoreTest/Program.cs

@@ -10,8 +10,12 @@ namespace NetCoreTest
     {
         public static void Main(string[] args)
         {
-            var rsaKey = RsaCrypt.GenerateRsaKeys();
+            var rsaKey = RsaCrypt.GenerateRsaKeys(RsaKeyType.PKCS8, 2048);
+            Console.WriteLine(rsaKey.PrivateKey);
+            Console.WriteLine(rsaKey.PublicKey);
             var enc = "123456".RSAEncrypt();
+            Console.WriteLine(enc);
+            Console.Beep();
             var dec = enc.RSADecrypt();
             Console.WriteLine(dec);
             Console.ReadKey();