1 /// <summary> 2 /// RSA私钥加密 3 /// </summary> 4 /// <param name="strValue">待加密的文本</param> 5 /// <param name="prkKey">私钥</param> 6 /// <returns></returns> 7 private string EncryptDataBytes(string strValue,string priKey) 8 { 9 if (string.IsNullOrEmpty(priKey)) 10 { 11 return ""; 12 } 13 try 14 { 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 }
时间: 2024-10-14 11:00:22