110,535
社区成员
发帖
与我相关
我的任务
分享
using System.Web.Security;
string 密文 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("明文", "MD5");
<connectionStrings configProtectionProvider="RsaProtectedConfigurationProvider">
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<KeyName>Rsa Key</KeyName>
</KeyInfo>
<CipherData>
<CipherValue>cGqkexvQnfv/zp5pRwxnTwGeAXo6BfG0MQtwr6rOhdWUxRZxixWmcnPhnK6AHHZj2hCcp/TyXTJenQitrdNatQaGg2sSHut0MmyLg3OZkpXmQu5+ankm37/k+FIOdx9pY2qKtQEWgWK3EffyOnpDAEv8V6hQ9RomJqhLmw/JT4w=</CipherValue>
</CipherData>
</EncryptedKey>
</KeyInfo>
<CipherData>
<CipherValue>k4OMiQEB9q4rHx9AavmEyBmvtsxY30kOr26D1aycMvWo6mZkWjDXFeGQcHdUkJa7Xd7oz/7ASjVvRoXYns6UfE9on00/VkfCZz/I95z0v+HR+KrXd9QaA3vre4qMc9GixnUr2Alz33otWg7lSdGKenD+eYIDfAmC/nHFOuN/NGavoD4j/NPBOeZw/CcMAqoMBPH/MVto7HkVxp3wOwD1SiZA+ldylycaSSNV8pS/Gmm3EaKNyFXrYB0YruntHTNz/LAhXDoz5s1d3Ol2BIp/MP3V9JM43WJbfFfqXGJjvKg=</CipherValue>
</CipherData>
</EncryptedData>
</connectionStrings>
<add name="NorthwindConnectionString" connectionString="Data Source=WSR-PC;Initial Catalog=Northwind;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
public static string GetMD5Hash(String input)
{
MD5 md5 = new MD5CryptoServiceProvider();
byte[] res = md5.ComputeHash(Encoding.Default.GetBytes(input), 0, input.Length);
char[] temp = new char[res.Length];
System.Array.Copy(res, temp, res.Length);
return new String(temp);
}
/// <summary>
/// 获得MD5的16进制结果
/// </summary>
public static string GetMD5HashHex(String input)
{
MD5 md5 = new MD5CryptoServiceProvider();
DES des = new DESCryptoServiceProvider();
byte[] res = md5.ComputeHash(Encoding.Default.GetBytes(input), 0, input.Length);
String returnThis = "";
for (int i = 0; i < res.Length; i++)
{
returnThis += System.Uri.HexEscape((char)res[i]);
}
returnThis = returnThis.Replace("%", "");
returnThis = returnThis.ToLower();
return returnThis;
}