`
bulote
  • 浏览: 1353940 次
文章分类
社区版块
存档分类
最新评论

webconfig加密

 
阅读更多

.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Configuration;

namespace WebConfig加密
{
<wbr><wbr><wbr> public partial class index : System.Web.UI.Page<br><wbr><wbr><wbr> {<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> protected void Page_Load(object sender, EventArgs e)<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> {</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<wbr><wbr><wbr><wbr><wbr><wbr><wbr> }</wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<wbr><wbr><wbr><wbr><wbr><wbr><wbr> Configuration myConfiguration = null;<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> ConfigurationSection myAppSettings = null;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<wbr><wbr><wbr><wbr><wbr><wbr><wbr> // DPAIP加密(用的最多)<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> protected void btnDPAIP_Click(object sender, EventArgs e)<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> {<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> try<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> {<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> getAppSettings(out myConfiguration, out myAppSettings);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> if (!myAppSettings.SectionInformation.IsProtected)<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> {<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> //DPAPI加密<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> myAppSettings.SectionInformation.ProtectSection</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> ("DataProtectionConfigurat<wbr>ionProvider");<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> //储存设定写入web.config文件<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> myConfiguration.Save();<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> Response.Write("用DPAIP加密成功");<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> }<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> }<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> catch (Exception ex)<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> {<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> Response.Write(ex.Message.ToString());<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> }<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> }</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<wbr><wbr><wbr><wbr><wbr><wbr><wbr> // RSA加密(需要设置权限,比较麻烦,用的不多)<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> protected void btnRSA_Click(object sender, EventArgs e)<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> {<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> try<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> {<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> getAppSettings(out myConfiguration, out myAppSettings);</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> if (!myAppSettings.SectionInformation.IsProtected)<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> {<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> //RSA加密<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> myAppSettings.SectionInformation.ProtectSection</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> ("RsaProtectedConfiguratio<wbr>nProvider");</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> //储存设定写入web.config文件<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> myConfiguration.Save();<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> Response.Write("以RSA加密成功!");<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> }<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> }<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> catch (Exception ex)<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> {<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> Response.Write(ex.Message.ToString());<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> }<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> }</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<wbr><wbr><wbr><wbr><wbr><wbr><wbr> //取得取得Web.config中appSettings设定区段(还可以根据需要,设置需要加密的节点)<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> protected void getAppSettings(out Configuration myConfig, out ConfigurationSection</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>appSettings)<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> {<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> //开启Request所在路径网站的Web.config文件<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> myConfig = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> //取得Web.config中appSettings设定区段<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> appSettings = myConfig.GetSection("appSettings");<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> }</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<wbr><wbr><wbr><wbr><wbr><wbr><wbr> // 完全解密<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> protected void btnResolve_Click(object sender, EventArgs e)<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> {<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> try<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> {<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> getAppSettings(out myConfiguration, out myAppSettings);<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> if (myAppSettings.SectionInformation.IsProtected)<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> {<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> myAppSettings.SectionInformation.UnprotectSection(); //解密<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> myConfiguration.Save();<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> }<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> Response.Write("appSettings解密成功!");<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> }<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> catch (Exception ex)<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> {<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> Response.Write(ex.Message.ToString());<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> }<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> }<br><wbr><wbr><wbr> }<br> }</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<wbr></wbr>

.aspx

<body>
<wbr><wbr><wbr> &lt;form id="form1" runat="server"&gt;<br><wbr><wbr><wbr> &lt;div&gt;<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> &lt;asp:Button ID="btnDPAIP" runat="server" Text="DPAIP加密" onclick="btnDPAIP_Click" /&gt;<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> &lt;br /&gt;<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> &lt;br /&gt;<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> &lt;asp:Button ID="btnRSA" runat="server" Text="RSA加密" onclick="btnRSA_Click" /&gt;<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> &lt;br /&gt;<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> &lt;br /&gt;<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr> &lt;asp:Button ID="btnResolve" runat="server" Text="完全解密"<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> onclick="btnResolve_Click" /&gt;<br><wbr><wbr><wbr> &lt;/div&gt;<br><wbr><wbr><wbr> &lt;/form&gt;<br> &lt;/body&gt;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>





加密前

<wbr> &lt;appSettings&gt;<br><wbr><wbr><wbr> &lt;add key="con" value="data source=.\SQLEXPRESS;Integrated</wbr></wbr></wbr></wbr>

<wbr><wbr><wbr> Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" /&gt;<br><wbr> &lt;/appSettings&gt;</wbr></wbr></wbr></wbr>

<wbr></wbr>

加密结果

<wbr> &lt;appSettings configProtectionProvider<wbr>="DataProtectionConfigurat<wbr>ionProvider"&gt;<br><wbr><wbr><wbr> &lt;EncryptedData&gt;<br><wbr><wbr><wbr><wbr><wbr> &lt;CipherData&gt;<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr>&lt;CipherValue&gt;AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAzCJXt/1660evq+/58WwHfAQAAAACAAAAAAADZgA<wbr>AqAAAABAAAABa4SlZnvwdFhV<wbr>lRr9PuT3hAAAAAASAAACgAAA<wbr>AEAAAAEDgN4H/IpjLojCaYhMXkudgAQAA1NHa<wbr>7mkrBWMGqXH9nmGi8Ie1Mnuh<wbr>1iD8hXaAzZ8/4UnzAwIyJBvLHln/Kv+LatS/w8hLkTR/GbnIkYhzeuk/ER1m76VUzuhRY7KcwdXkZkOx<wbr>elEjWZU/jA7wcvgyEN7OkRyhV0nz98zH<wbr>I+XdxQkFsLEltNacCqBx3PgCkX<wbr>+sKz1hyzp06D0QQOIbqoaNSWl<wbr>/QuBAIxlZohAKaTxAQcnKjrOu<wbr>Bofp49N4OCbDFdoIFMfWaoCS<wbr>fQV0xQUEVRCkBzzd/FGVjrSYeLgk9CM9vdSnioLUD<wbr>IMv62dxqEYM/0dRd4qhYTghIzWwe/POKR8IxUC++zRT/kEKh5cTw8OppW+mU1+6oqul98jxxk//UJ/HyVEBZ8XAVhetcSjUH1eXyzB<wbr>cup03L8V+WnEmqAwzoibMpDmTkXIEitSZ<wbr>RJ/8Fy26hByUJkslQFYdtLgZ92O<wbr>CLfSVCW3etWXDtMpD7cfJuMP<wbr>6XBQAAAAYjlMjewxEJfZKD64<wbr>skP+Lnh5x6w==&lt;/CipherValue&gt;<br><wbr><wbr><wbr><wbr><wbr> &lt;/CipherData&gt;<br><wbr><wbr><wbr> &lt;/EncryptedData&gt;<br><wbr> &lt;/appSettings&gt;</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<wbr></wbr>

加密一般用在神马时候呢?

<wbr></wbr>

当你把这个程序发布给用户,发布之前,你需要把你不希望暴露给用户的信息的节点加密。

分享到:
评论

相关推荐

    Asp.net WebConfig加密解密.rar

    案例通过利用微软提供的方式(RSAProtectedConfigurationProvider和DataProtectionConfgurationProvider)对Web.Config 中的数据库连接字符串进行加密和解密操作

    WEBCONFIG数据库链接加密解密算法

    WebConfigEncryptDecrypt.aspx和WebConfigEncryptDecrypt.aspx.cs这两个文件很可能是一个简单的ASP.NET Web应用程序,用于实现Web.config文件中数据库连接字符串的加密和解密功能。WebConfigEncryptDecrypt.aspx可能...

    webconfig连接字符串的加密和解密

    webconfig连接字符串的加密和解密方法,附加可能出现的问题及解决方案

    webconfig加解密

    3. 第三方工具:有一些第三方工具,如WebConfigTransform、RsaProtectedConfigurationProvider等,提供了更友好的界面和额外功能来处理WebConfig加密。 四、解密WebConfig 加密的WebConfig在运行时会被自动解密,...

    加密数据库联接字符串

    加密数据库联接字符串 webConfig加密

    WebConfig详解及绿色编辑器

    3. WebConfig加密 为了保护敏感信息,如数据库连接字符串,开发者可以使用ASP.NET提供的`aspnet_regiis.exe`工具对WebConfig的部分或全部内容进行加密。通过这个工具,可以使用数据保护提供程序(DPAPI)或RSA算法...

    webconfige加密解密

    ### WebConfig 加密解密详解 #### 一、概述 在.NET Framework中,为了保护配置文件(web.config)中的敏感信息不被未授权访问或泄露,引入了一套加密解密机制。这种机制允许开发者对诸如连接字符串(connection ...

    博客中web.config的加密与解密的Demo

    在提供的`WebConfig加密与解密`压缩包中,可能包含了一个示例项目,演示了如何在代码中调用`ConfigurationManager`类的`ProtectedData`方法进行加密和解密。这个Demo可能包括了以下步骤: 1. 创建一个类库项目,...

    .net中webconfig配置节加密与解密详解

    ### .NET中Web.config配置节加密与解密详解 #### 一、引言 在.NET框架下开发的应用程序中,`Web.config` 文件扮演着极其重要的角色,它不仅包含了应用程序的配置信息,还可能存储了敏感数据如数据库连接字符串等。...

    加密webconfig中的连接字串

    在Web.config中明文存储数据库连接字符串可能会导致敏感信息泄露,因此,加密Web.config中的连接字符串就显得尤为重要。 一、为什么需要加密连接字符串? 1. 安全性:连接字符串通常包含数据库服务器名、数据库名、...

    web.config加密与解密

    为了保护这些信息不被未授权的用户查看或修改,开发者有时会选择对`web.config`中的部分或全部内容进行加密。本文将深入探讨`web.config`的加密与解密机制,以及如何在实践中操作这一过程。 首先,我们需要了解ASP...

    web.config加密工具

    为了保护这些信息不被未授权的用户访问或篡改,我们可以对`web.config`文件进行加密。本文将详细介绍`web.config`加密工具及其应用。 `web.config`文件是ASP.NET应用程序的核心配置文件,它存储了应用的配置设置,...

    asp.net web URL 伪装或加密

    ASP.NET Web 应用程序中的URL伪装或加密是一种安全措施,用于保护应用程序的URL结构不被轻易解析或篡改,从而提高网站的安全性。在本文中,我们将深入探讨这一主题,了解其背后的原理、实现方法以及它如何帮助保护你...

    .net加密解密工具

    webconfig加解密工具,可适用于用户密码加密,数据库连接字符串加密等等

    .Net Framwork自带的工具Aspnet_regiis加密解密web.config

    标题中的".Net Framework自带的工具Aspnet_regiis加密解密web.config"是指在.NET Framework环境下,开发者可以利用一个名为`aspnet_regiis.exe`的命令行工具来对Web应用程序的`web.config`配置文件进行加密和解密...

    Demo10_webconfig配置.rar

    在"Demo10_webconfig配置.rar"这个模块中,我们主要探讨的是如何根据不同的需求来定制Web.config配置文件,以满足网站的特定功能需求。 首先,Web.config文件是ASP.NET应用程序的基础配置中心,它定义了全局的设置...

    web.config machineKey 生成的算法

    其中,`machineKey`元素是用于加密和解密数据的关键部分,特别是在会话状态管理、视图状态验证以及表单身份验证票证等方面。本篇文章将深入探讨`machineKey`生成的算法及其应用。 `machineKey`元素在`web.config`中...

    加密Web.Config中的ConnectionString

    标题“加密Web.Config中的ConnectionString”涉及的是在ASP.NET应用程序中保护敏感信息,特别是数据库连接字符串的安全问题。在Web.Config文件中,ConnectionString用于存储应用程序访问数据库的详细信息,如服务器...

    修改数据库字符串配置及测试

    在这个场景中,我们关注的是如何在C#编程环境中处理数据库连接字符串的修改和加密,以及如何将这些配置存储在Web.config文件中。Web.config文件是ASP.NET应用中的核心配置文件,用于存储应用程序的设置,如数据库...

Global site tag (gtag.js) - Google Analytics