asp.net2.0加密数据库联接字符串
asp.net2.0如何加密数据库联接字符串 1.添加密钥 2.添加web.config节点 decrypt" name="hnlaw" type="system.configuration.rsaprotectedconfigurationprovider,system.configuration, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a" /> 3.加密web.config "hnlaw" "hnlaw" 最后就是要注意:做完后找到c:documents and settingsll userspplication datamicrosoftcrypto samachinekeys目录下,找到生成 的密钥文件(可按时间查找),给上network service可读取权限,不然会出现error message from the provider: the rsa key container could not be opened. 这样可能会出现,如果没有自己的服务器,没有权限修改machinekeys目录,不知道还有其它解决办法,希望大家共享一下:) http://kary.cnblogs.com/archive/2006/05/19/404204.html
在asp.net2.0中,发布网站时,加密web.config,这样可以有效保证数据库用户和密码安全,其步骤如下:
执行:c:windowsmicrosoft.net ramework 2.0.50727spnet_regiis -pc "hnlaw" -exp
其中"hnlaw"为密钥名称
在web.config的<configuration></configuration>之间添加:
<configprotecteddata>
<providers>
<add keycontainername="hnlaw" usemachinecontainer="true" description="uses rsacryptoserviceprovider to encrypt and
</providers>
</configprotecteddata>
注意:这里keycontainername="hnlaw"和name="hnlaw"分别表示你的密钥名称;
到网站根目录添加一个批处理文件enweb.bat,内容如下:
@echo off
c:windowsmicrosoft.net ramework 2.0.50727spnet_regiis -pef "system.web/identity" "e:hs studiodonet2hnlawyer" -prov
c:windowsmicrosoft.net ramework 2.0.50727spnet_regiis -pef "connectionstrings" "e:hs studiodonet2hnlawyer" -prov
pause
注册上面的的路径和名称!
运行后出现成功!
4.解密
同样到网站根目录添加一个批处理文件deweb.bat,内容如下:
@echo off
c:windowsmicrosoft.net ramework 2.0.50727spnet_regiis -pef "system.web/identity" "e:hs studiodonet2hnlawyer"
c:windowsmicrosoft.net ramework 2.0.50727spnet_regiis -pdf "connectionstrings" "e:hs studiodonet2hnlawyer"
pause
无法读取
Tag: 加密
文章整理:iocblog
版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。