国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net2.0如何加密數(shù)據(jù)庫聯(lián)接字符串

2024-07-10 13:10:42
字體:
供稿:網(wǎng)友

asp.net2.0如何加密數(shù)據(jù)庫聯(lián)接字符串
在asp.net2.0中,發(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)容如下:
 @echo off
 c:/windows/microsoft.net/framework/v2.0.50727/aspnet_regiis -pef "system.web/identity" "e:/hs  studio/donet2/hnlawyer" -prov

"hnlaw"
  c:/windows/microsoft.net/framework/v2.0.50727/aspnet_regiis -pef "connectionstrings" "e:/hs  studio/donet2/hnlawyer" -prov

"hnlaw"
pause
注冊(cè)上面的的路徑和名稱!
運(yùn)行后出現(xiàn)成功!
4.解密
同樣到網(wǎng)站根目錄添加一個(gè)批處理文件deweb.bat,內(nèi)容如下:
 @echo off
c:/windows/microsoft.net/framework/v2.0.50727/aspnet_regiis -pef "system.web/identity" "e:/hs  studio/donet2/hnlawyer"
c:/windows/microsoft.net/framework/v2.0.50727/aspnet_regiis -pdf "connectionstrings" "e:/hs  studio/donet2/hnlawyer"
pause

最后就是要注意:做完后找到c:/documents and settings/all users/application data/microsoft/crypto/rsa/machinekeys目錄下,找到生成

的密鑰文件(可按時(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目錄,不知道還有其它解決辦法,希望大家共享一下:)

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 扬中市| 屏边| 昔阳县| 绍兴县| 丰县| 启东市| 汤原县| 托克逊县| 双城市| 县级市| 化德县| 水富县| 洛浦县| 屏南县| 宁都县| 金寨县| 抚松县| 新巴尔虎右旗| 枣庄市| 辽阳县| 河间市| 延长县| 静海县| 旺苍县| 灵石县| 黄浦区| 桃源县| 安龙县| 乌鲁木齐县| 绥宁县| 马鞍山市| 海丰县| 揭西县| 宝兴县| 龙山县| 黑河市| 滨州市| 泾源县| 江陵县| 新和县| 黔西县|