浏览代码

访问权限

懒得勤快 5 年之前
父节点
当前提交
0953c0356c
共有 2 个文件被更改,包括 7 次插入3 次删除
  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();