Ejemplo n.º 1
0
 /// <summary>
 /// 解密
 /// </summary>
 /// <param name="encryptedText">密文</param>
 /// <param name="decryptedText">明文</param>
 /// <returns></returns>
 public static bool Decrypt(string encryptedText, out string decryptedText)
 {
     try
     {
         var path = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "/dotnetcore/rsakeys/RSA.Private" : "C:\\ProgramData\\MyRSAKeys\\RSA.Private";
         decryptedText = RsaHelperForGui.Decrypt(encryptedText, path);
         return(true);
     }
     catch (Exception)
     {
         decryptedText = encryptedText;
         return(false);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 加密
 /// </summary>
 /// <param name="plaintText">明文</param>
 /// <param name="encryptedText">密文</param>
 /// <returns></returns>
 public static bool Encrypt(string plaintText, out string encryptedText)
 {
     try
     {
         var path = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "/dotnetcore/rsakeys/RSA.Pub" : "C:\\ProgramData\\MyRSAKeys\\RSA.Pub";
         encryptedText = RsaHelperForGui.Encrypt(plaintText, path);
         return(true);
     }
     catch (Exception)
     {
         encryptedText = plaintText;
         return(false);
     }
 }