From 1c60c67849eb5d0b46488bd3588d73a474580c4a Mon Sep 17 00:00:00 2001 From: owenchen Date: Thu, 14 May 2026 14:56:31 +0800 Subject: [PATCH] ow --- CloudBuilder.Core/Utility/RSA.cs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/CloudBuilder.Core/Utility/RSA.cs b/CloudBuilder.Core/Utility/RSA.cs index 7d8650b..f97a7c2 100644 --- a/CloudBuilder.Core/Utility/RSA.cs +++ b/CloudBuilder.Core/Utility/RSA.cs @@ -1,6 +1,28 @@ -using System.Security.Cryptography; +using System; +using System.Security.Cryptography; using System.Text; +/* + RSA rSA = new RSA(); + //公钥 + string pubkey = rSA.ToPEM_PKCS1(true); + //私钥 + string priKey = rSA.ToPEM_PKCS1(); + //公钥加密 + RSA rrSA = new RSA(pubkey, true); + string abc123=rrSA.Encode("abc123"); + --------------------------------------------------------------------------------- + 前端公钥加密 + let encrypt = new JSEncrypt(); + encrypt.setPublicKey(pubkey); + data.RsaUserPassword = encrypt + .encrypt(data.UserPassword + CryptoJS.MD5(state.LoginData.UserPassword)) + .toString(); + --------------------------------------------------------------------------------- + //私钥解密 + rrSA = new RSA(priKey, true); + string desc = rrSA.DecodeOrNull(abc123); +*/ namespace System { /// @@ -181,6 +203,10 @@ namespace System rsaParams.Flags = CspProviderFlags.UseMachineKeyStore; rsa = new RSACryptoServiceProvider(rsaParams); } + public RSA() : this(2048) + { + + } /// /// 用指定密钥大小创建一个新的RSA,出错抛异常