上传者: u011435873
|
上传时间: 2022-03-21 10:05:25
|
文件大小: 3.08MB
|
文件类型: -
// 加载公钥
RsaKeyParameters pubkey;
using (var sr = new StreamReader(ConfigurationManager.AppSettings["PubKey"]))
{
var pemReader = new Org.BouncyCastle.OpenSsl.PemReader(sr);
pubkey = (RsaKeyParameters)pemReader.ReadObject();
}
// 初始化cipher
var cipher = (BufferedAsymmetricBlockCipher)CipherUtilities.GetCipher("RSA/ECB/OAEPWITHSHA-1ANDMGF1PADDING");
cipher.Init(true, pubkey);
// 加密message
var message = Encoding.UTF8.GetBytes(EncryptString);
var output = EncryptUtil.Encrypt(message, cipher);
R = Convert.ToBase64String(output);