我使用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