This commit is contained in:
owenchen 2026-05-14 14:56:31 +08:00
parent a85e87d330
commit 1c60c67849

View File

@ -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
{
/// <summary>
@ -181,6 +203,10 @@ namespace System
rsaParams.Flags = CspProviderFlags.UseMachineKeyStore;
rsa = new RSACryptoServiceProvider(rsaParams);
}
public RSA() : this(2048)
{
}
/// <summary>
/// 用指定密钥大小创建一个新的RSA出错抛异常