日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

淺談ASP.NET2.0中配置文件的加密與解密_.Net教程

編輯Tag賺U幣
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!

推薦:ASP.NET遍歷配置文件的連接字符串
在ASP.NET 2.0中,提供了更方便的配置文件訪問(wèn)的類,具體可以到System.Configuration名稱空間下進(jìn)行查看。本文提供一種在開發(fā)過(guò)程中常用的得到數(shù)據(jù)庫(kù)字符串的方法,為方便使用,寫成一個(gè)方法進(jìn)行調(diào)用: 以下為引用的內(nèi)容: public string GetConnectionStrin

首先添加引用: using System.Web.Configuration;

加密操作如下:

以下為引用的內(nèi)容:

private void ProtectSection(string sectionName, string provider)
{
Configuration config =
WebConfigurationManager.
OpenWebConfiguration(Request.ApplicationPath);

ConfigurationSection section = config.GetSection(sectionName);

if (section != null && !section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection(provider);
config.Save();
}
}

解密操作如下:

以下為引用的內(nèi)容:


private void UnProtectSection(string sectionName)
{
Configuration config =
WebConfigurationManager.
OpenWebConfiguration(Request.ApplicationPath);

ConfigurationSection section = config.GetSection(sectionName);

if (section != null && section.SectionInformation.IsProtected)
{
section.SectionInformation.UnprotectSection();
config.Save();
}
}


實(shí)踐:

加密前的配置文件:

以下為引用的內(nèi)容:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="name" value="shy520" />
<add key="address" value="cnblogs" />
</appSettings>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
加密后的配置文件:
<?xml version="1.0"?>
<configuration>
<appSettings configProtectionProvider="DataProtectionConfigurationProvider">
<EncryptedData>
<CipherData>
<CipherValue>
AQAAANCMnd8BFdERjHoAwE/Cl s
BAAAABi1ATlNkEUGEf0XyWGL2Xg
QAAAACAAAAAAADZgAAqAAAABAAA
ABIhxMWlazAntwIIpST1CDXAAAA
AASAAACgAAAAEAAAAPz/YKYx07c
b h4fqdr4fkLgAAAAX1Ieyc WSx
AfsDW1vn2C/fXsG2TAnYeUgaCov
8e3nGFTHHsH91gLiqKregFPYzGR
vW1xrez/3VwOmJI9eS7EFKrcXej
NnHL66kg2iNRk3ntLNZlZtTs3cZ
9w63u47VKAjs6miWsGBz2GntL/9
UGHLELigrJcr3YJ lsjOscExQnv
HGvA48EfxpD tEiFBtgXeHsFkQX
cqGySshx16vCt2GUNUC3ZmEAhBh
UsAFkPIYqelYHd4 m9a/xPe2tqw
GIbla1wbW2NDEfrzJPwnkfmpNqR
hXijKImipwXbDVYy6o0UAAAAs8D
suYNOhJ7qAjJa2c/4eUC7sks=
</CipherValue>
</CipherData>
</EncryptedData>
</appSettings>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>

分享:探討.Net整合其他平臺(tái)
整合分布式應(yīng)用程序經(jīng)常是一件非常困難并且錯(cuò)綜復(fù)雜的任務(wù),即使是最富有經(jīng)驗(yàn)的開發(fā)者也可能會(huì)覺(jué)得頭疼。當(dāng)應(yīng)用程序在不同的操作系統(tǒng)以及涉及不同的程序平臺(tái)時(shí),這個(gè)集成問(wèn)題變得尤其復(fù)雜。雖然說(shuō),Web服務(wù)承諾可以減輕程序員完成集成任務(wù)的困難程度,但是也

來(lái)源:模板無(wú)憂//所屬分類:.Net教程/更新時(shí)間:2009-05-26
相關(guān).Net教程