由于项目要求,在web.config中,数据库的链接配置connectionstring不允许password以明文的方式出现,所以在password中加了密。但我们使用了ms report(rdlc)报表工具,就会建立一个dataset,在dataset配置中,就会选择使用web.config当中配置的connectionstring,这样就造成了数据集中,任何datatableadapter都是无法登陆到数据库中的。
请问各位,有没有什么好的建议,能够达到以上要求?
请问各位,有没有什么好的建议,能够达到以上要求?
/// DES加密字符串
public static string Encrypt(string encryptString, string encryptKey)
{
try
{
byte[] rgbKey = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 8));
byte[] rgbIV = Keys;
byte[] inputByteArray = Encoding.UTF8.GetBytes(encryptString);
DESCryptoServiceProvider dCSP = new DESCryptoServiceProvider();
MemoryStream mStream = new MemoryStream();
CryptoStream cStream = new CryptoStream(mStream, dCSP.CreateEncryptor(rgbKey, rgbIV), CryptoStreamMode.Write);
cStream.Write(inputByteArray, 0, inputByteArray.Length);
cStream.FlushFinalBlock();
return Convert.ToBase64String(mStream.ToArray());
}
catch
{
return encryptString;
}
}
/// DES解密字符串
public static string Decrypt(string decryptString, string decryptKey)
{
try
{
byte[] rgbKey = Encoding.UTF8.GetBytes(decryptKey);
byte[] rgbIV = Keys;
byte[] inputByteArray = Convert.FromBase64String(decryptString);
DESCryptoServiceProvider DCSP = new DESCryptoServiceProvider();
MemoryStream mStream = new MemoryStream();
CryptoStream cStream = new CryptoStream(mStream, DCSP.CreateDecryptor(rgbKey, rgbIV), CryptoStreamMode.Write);
cStream.Write(inputByteArray, 0, inputByteArray.Length);
cStream.FlushFinalBlock();
return Encoding.UTF8.GetString(mStream.ToArray());
}
catch
{
return decryptString;
}
}
aspnet_regiis -pa "NetFrameworkConfigurationKey" "NT AUTHORITY\NETWORK SERVICE"
XP下:aspnet_regiis -pa "NetFrameworkConfigurationKey" "aspnet"
加密:aspnet_regiis -pe "appSettings" -app "/应用程序名 "
解密:aspnet_regiis -pd "appSettings" -app "/应用程序名 RDLC绑定数据集