在我們發(fā)布網(wǎng)站時(shí),加密web.config,這樣可以有效保證數(shù)據(jù)庫用戶和密碼安全,其步驟如下:
1.添加密鑰
執(zhí)行:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pc "hnlaw" -exp
其中"hnlaw"為密鑰名稱
2.添加web.config節(jié)點(diǎn)
在web.config的configuration>/configuration>之間添加:
configProtectedData> providers> add keyContainerName="hnlaw" useMachineContainer="true" description="Uses RsaCryptoServiceProvider to encrypt and decrypt" name="hnlaw" type="System.Configuration.RsaProtectedConfigurationProvider,System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> /providers> /configProtectedData>
注意:這里keyContainerName="hnlaw"和name="hnlaw"分別表示你的密鑰名稱;
3.加密web.config
到網(wǎng)站根目錄添加一個(gè)批處理文件enweb.bat,內(nèi)容如下:
運(yùn)行后出現(xiàn)成功!
4.解密
同樣到網(wǎng)站根目錄添加一個(gè)批處理文件deweb.bat,內(nèi)容如下:
的密鑰文件(可按時(shí)間查找),給上network service可讀取權(quán)限,不然會(huì)出現(xiàn)Error message from the provider: The RSA key container could
not be opened.
無法讀取
這樣可能會(huì)出現(xiàn),如果沒有自己的服務(wù)器,沒有權(quán)限修改MachineKeys目錄,不知道還有其它解決辦法,希望大家共享一下 :)
標(biāo)簽:德陽 張家界 新疆 江蘇 天門 陽泉 蘭州 白山
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《在asp.net中使用加密數(shù)據(jù)庫聯(lián)接字符串保證數(shù)據(jù)安全》,本文關(guān)鍵詞 在,asp.net,中,使用,加密,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。