|
您的位置: 首页 > 网站资讯 > asp.net2.0如何加密数据库联接字符串 |
asp.net2.0如何加密数据库联接字符串发布日期:2017/8/20
在asp.net2.0中,发布网站时,加密web.config,这样可以有用保证数据库用户和安全,其步骤如下 1.添加密钥 执行cwindowsmicrosoft.netframeworkv2.0.50727aspnet_regiis-pchnlaw-exp 其中hnlaw为密钥名称 2.添加web.config节点 在web.config的configurationconfiguration之间添加 configprotecteddata providers addkeycontainername=hnlawusemachinecontainer=truedescription=usesrsacryptoserviceprovidertoencryptand decryptname=hnlawtype=system.configuration.rsaprotectedconfigurationprovider,system.configuration, version=2.0.0.0, culture=neutral,publickeytoken=b03f5f7f11d50a3a providers configprotecteddata 注重这里keycontainername=hnlaw和name=hnlaw分别透露表现你的密钥名称; 3.加密web.config 到网站根目录添加一个批处理文件enweb.bat,内容如下 @echooff cwindowsmicrosoft.netframeworkv2.0.50727aspnet_regiis-pefsystem.webidentityehsstudiodonet2hnlawyer-prov hnlaw cwindowsmicrosoft.netframeworkv2.0.50727aspnet_regiis-pefconnectionstringsehsstudiodonet2hnlawyer-prov hnlaw pause 注册上面的的路径和名称! 运行后出现成功! 4.解密 同样到网站根目录添加一个批处理文件deweb.bat,内容如下 @echooff cwindowsmicrosoft.netframeworkv2.0.50727aspnet_regiis-pefsystem.webidentityehsstudiodonet2hnlawyer cwindowsmicrosoft.netframeworkv2.0.50727aspnet_regiis-pdfconnectionstringsehsstudiodonet2hnlawyer pause 就是要注重做完后找到cdocumentsandsettingsallusersapplicationdatamicrosoftcryptorsamachinekeys目录下,找到生 成 的密钥文件(可按时间查找),给上networkservice可读取权限,不然会出现errormessagefromtheproviderthersakey containercould notbeopened.无法读取 |
其他相关文章 |
|
|
|
|||||||||
Copyright 2012-2024 上海蒙狼网络科技有限公司 WWW.MENGL.CN All Rights Reserved |