Ejemplo n.º 1
0
 /// <summary>
 /// 私钥加密
 /// </summary>
 /// <param name="privateKey"></param>
 /// <param name="bytes"></param>
 /// <returns></returns>
 public static byte[] PrivateEncrypt(string privateKey, byte[] bytes)
 {
     using (RsaEncryption rsa = new RsaEncryption()) {
         rsa.LoadPrivateFromXml(privateKey);
         return(rsa.PrivateEncryption(bytes));
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 私钥加密
 /// </summary>
 /// <param name="privateKey"></param>
 /// <param name="EncryptString"></param>
 /// <returns></returns>
 public static string PrivateEncrypt(string privateKey, string EncryptString)
 {
     using (RsaEncryption rsa = new RsaEncryption()) {
         rsa.LoadPrivateFromXml(privateKey);
         var bs = Encoding.UTF8.GetBytes(EncryptString);
         return(Convert.ToBase64String(rsa.PrivateEncryption(bs)));
     }
 }