我使用Entity Framework
創建數據庫的具有密碼的SQLServer的連接:ECRYPT密碼的app.config
connectionString="DataSource=|DataDirectory|DB.sdf;Password=abc
如何保護密碼,而使用實體框架?
我使用Entity Framework
創建數據庫的具有密碼的SQLServer的連接:ECRYPT密碼的app.config
connectionString="DataSource=|DataDirectory|DB.sdf;Password=abc
如何保護密碼,而使用實體框架?
ConnectionStringsSection oSection = Configuration.ServiceConfiguration.GetConnectionStrings();
if(!oSection.SectionInformation.IsLocked && !oSection.SectionInformation.IsProtected)
{
oSection.SectionInformation.ProtectSection("RSAProtectedConfigurationProvider");
oSection.CurrentConfiguration.Save();
}
如果您有權訪問服務器,則可以使用cmd中的Web配置加密工具。我創建在同一文件夾.bat文件作爲包含我的web.config:
aspnet_regiis -pef connectionStrings .
aspnet_regiis -pef appSettings .
pause
這將加密的ConnectionStrings整段,在我的情況下,整體的appSettings節了。
解密,這樣做:
aspnet_regiis -pdf connectionStrings .
aspnet_regiis -pdf appSettings .
pause
您需要雖然從服務器上運行此。
您可以通過使用樣品從這裏寫EncDecHelper.Decrypt
:Encrypt/Decrypt string in .NET
您將在這裏找到了相關信息:Encrypt password in App.config
是否與實體框架這項工作,因爲上面的代碼將加密連接字符串。 – Alvin