aspnet字元串加密
㈠ 如何對web.config進行加密和解密
你好,可以使用受保護配置來加密 Web 應用程序配置文件(如 Web.config 文件)中的敏感信息(包括用戶名和密碼、資料庫連接字元串和加密密鑰)。對配置信息進行加密後,即使攻擊者獲取了對配置文件的訪問,也可以使攻擊者難以獲取對敏感信息的訪問,從而改進應用程序的安全性。 針對asp.net 2.0的應用程序的資料庫鏈接字元串進行加密:例如,未加密的配置文件中可能包含一個指定用於連接到資料庫的連接字元串的節,如下面的示例所示: <configuration> <connectionStrings>
<add name="SampleSqlServer" connectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;" />
</connectionStrings>
</configuration>
ASP.NET 2.0 中有一個新的安全特性.可以對 Web.config 文件中的任何配置節進行加密處理,可以通過手工運行工具aspnet_regiis或者編程來完成這個工作。如果你可以直接訪問你的Web 伺服器,你可以通過運行如下的命令行: cd %windows%/Microsoft.NET/Framework/versionNumber aspnet_regiis -pe "connectionStrings" -app "/SampleApplication" –prov -pd section
對配置節進行解密。此參數採用下面的可選參數: · -app virtualPath 指定應該在包含路徑的級別進行解密。 · -location subPath 指定要解密的子目錄。 · -pkm 指定應該對 Machine.config 而非 Web.config 文件進行解密。
-pdf section webApplicationDirectory
對指定物理(非虛擬)目錄中的 Web.config 文件的指定配置節進行解密。
-pe section
對指定的配置節進行加密。此參數採用下面的可選修飾符: · -prov provider 指定要使用的加密提供程序。 · -app virtualPath 指定應該在包含路徑的級別進行加密。 · -location subPath 指定要加密的子目錄。 · -pkm 指定應該對 Machine.config 而非 Web.config 文件進行加密。
-pef section webApplicationDirectory
對指定物理(非虛擬)目錄中的 Web.config 文件的指定配置節進行加密。
如果你是使用虛擬主機等不能訪問物理的伺服器,你仍然能夠通過編程方式加密的連接字元串: 1 Configuration config = Configuration.GetWebConfiguration(Request.ApplicationPath);
2 ConfigurationSection section = config.Sections["connectionStrings"];
3 section.SectionInformation.ProtectSection("");;
4 config.Update ();或者 config.Save();
//加密web.Config中的指定節
private void ProtectSection(string sectionName)
{
Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
ConfigurationSection section = config.GetSection(sectionName);
if (section != null && !section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection("");
config.Save();
}
}
//解密web.Config中的指定節
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();
}
}
㈡ 如何解密下面的字元串 它是什麼加密方式
解密為:
通過本工具可以快速檢測網頁的META標簽,分析標題、關鍵詞、描述等是否有利於搜索引擎收錄
㈢ asp.net網站管理工具注冊了一個用戶,為什麼在aspnet_users表裡面找不到但是還能登錄啊
不是找不到,因為你採用。net自帶的用戶控制的話,所有創建的用戶都是加密的,一般情況下,你並不能看到明文。你可以通過統計該表的數據條數,來驗證,是否有數據增加。
㈣ c# web.config加密有什麼用處
加密必然是為了保護敏感信息(比如,資料庫聯接字元串) ,或者你不想要給其他人看到的信息。
經常會被加密的節點又一下幾個:
1) <appSettings> 一般包含一些我們自定義的信息。
2) <connectionStrings> 這個比較容易理解,包含連接資料庫用的字元串。
3) <identity> 包含使用impersonate時的賬戶信息。
4) <sessionState> 包含將session置於process外的連接字元串。
總之,加密的主要目的是為了安全, 信息安全,知識產權安全等。
ASP.NET提供了兩種加密方式,DPAPI和RSA。我們可以選擇其中一種方式來加密我們的web.config。具體加密方式也有兩種,利用aspnet_regiis.exe工具或在程序中用代碼加密。