步驟1:創(chuàng)建加密命令
使用ASP.NET提供的命令工具aspnet_regiis來創(chuàng)建加密命令。
1、打開控制臺窗口,在命令行中輸入以下命令:?
cd C:\Windows\Microsoft.NET\Framework\v4.xxxxx
aspnet_regiis.exe -pef connectionStrings "C:\MyAppFolder" -prov "DataProtectionConfigurationProvider"
這個命令將加密App.config文件中的connectionStrings設(shè)置。C:\MyAppFolder是應(yīng)用程序的根目錄。?
2、打開控制臺窗口,在命令行中輸入以下命令:?
cd C:\Windows\Microsoft.NET\Framework\v4.xxxxx
aspnet_regiis.exe -pef "appSettings" "C:\MyAppFolder" -prov "DataProtectionConfigurationProvider"
這個命令將會加密Web.config文件中的appSettings設(shè)置。?
?步驟2:解密加密的配置節(jié)
?如果需要編輯加密的配置節(jié),可以使用aspnet_regiis提供的解密命令。
1、打開控制臺窗口,在命令行中輸入以下命令:?
cd C:\Windows\Microsoft.NET\Framework\v4.xxxxx
aspnet_regiis.exe -pdf connectionStrings "C:\MyAppFolder"
這個命令將解密App.config文件中的connectionStrings設(shè)置。C:\MyAppFolder是應(yīng)用程序的根目錄。?
2、打開控制臺窗口,在命令行中輸入以下命令:?
cd C:\Windows\Microsoft.NET\Framework\v4.xxxxx
aspnet_regiis.exe -pdf "appSettings" "C:\MyAppFolder"
這個命令將會解密Web.config文件中的appSettings設(shè)置。?
示例?
?文章來源:http://www.zghlxwxcb.cn/news/detail-632836.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-632836.html
到了這里,關(guān)于C# App.config和Web.config加密的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!