您的位置:首页 > 博客中心 > 数据库 >

ASP.NET数据库连接字符串的加密与解密

时间:2022-03-10 17:20

注意的是加密、解密必须在一台机器上完成。

-----------------------------

下面显示的是通过代码方式对数据库连接字符串加密,代码如下:

Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);

ConfigurationSection configSection = config.GetSection("connectionStrings");

if (configSection.SectionInformation.IsProtected)

...{//如果已经加密,就不用再加密了

configSection.SectionInformation.UnprotectSection();

config.Save();

}

else

...{

configSection.SectionInformation.ProtectSection ("DataProtectionConfigurationProvider");

config.Save();

}

ASP.NET数据库连接字符串的加密与解密,布布扣,bubuko.com

热门排行

今日推荐

热门手游