1 ///2 /// RSA私钥加密 3 /// 4 /// 待加密的文本 5 /// 私钥 6 ///7 private string EncryptDataBytes(string strValue,string priKey) 8 { 9 if (string.IsNullOrEmpty(priKey))10 {11 return "";12 }13 try14 {15 RSACryptoServiceProvider.UseMachineKeyStore = true;16 RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();17 //私钥18 RSA.FromXmlString(priKey);19 byte[] signData = rsa.SignData(Encoding.UTF8.GetBytes(strValue), CryptoConfig.MapNameToOID("SHA1"));20 return Convert.ToBase64String(signData);21 }22 catch (Exception ex)23 {24 log.Warn(ex.Message);25 return "";26 }27 }