RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
byte[] cipherbytes;
RsaKeyParameters publickeyParam = (RsaKeyParameters)PublicKeyFactory.CreateKey(Convert.FromBase64String(spk));//spk为公钥
string XML = string.Format("<RSAKeyValue><Modulus>{0]</Modulus><Exponent>{1}</Exponent><RSAKeyValue>",
Convert.ToBase64String(publicKeyParam.Modulus.ToByteArrayUnsigned()),
Convert.ToBase64String(publicKeyParam.Exponent.ToByteArrayUnsigned()));
rsa.FromXmlString(XML);
cipherbytes = rsa.Encrypt(Encoding.UTF8.GetBytes(userid),false);//userid为加密内容
string data = Convert.ToBase64String(cipherbytes);//加密后参数
标签:Convert,加密,string,C#,RSA,rsa,ToBase64String,cipherbytes From: https://www.cnblogs.com/Net191111/p/17594185.html