﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-willblogs-最新评论</title><link>http://www.cnitblog.com/willblogs/CommentsRSS.aspx</link><description>will</description><language>zh-cn</language><pubDate>Thu, 22 Feb 2007 18:03:32 GMT</pubDate><lastBuildDate>Thu, 22 Feb 2007 18:03:32 GMT</lastBuildDate><generator>cnblogs</generator><item><title>asp.net2.0如何加密数据库联接字符串</title><link>http://www.cnitblog.com/willblogs/archive/2008/04/03/23025.html#41899</link><dc:creator>陈小小</dc:creator><author>陈小小</author><pubDate>Thu, 03 Apr 2008 07:18:00 GMT</pubDate><guid>http://www.cnitblog.com/willblogs/archive/2008/04/03/23025.html#41899</guid><description><![CDATA[asp.net2.0如何加密数据库联接字符串<br><br>在asp.net2.0中,发布网站时,加密web.config,这样可以有效保证数据库用户和密码安全,其步骤如下:<br><br>1.添加密钥<br>执行:c:\windows\microsoft.net\framework\v2.0.50727\aspnet_regiis -pc &quot;hnlaw&quot; -exp<br>其中&quot;hnlaw&quot;为密钥名称<br><br>2.添加web.config节点<br>在web.config的&lt;configuration&gt;&lt;/configuration&gt;之间添加:<br>&lt;configprotecteddata&gt;<br>  &lt;providers&gt;<br>   &lt;add keycontainername=&quot;hnlaw&quot; usemachinecontainer=&quot;true&quot; description=&quot;uses rsacryptoserviceprovider to encrypt and <br><br>decrypt&quot; name=&quot;hnlaw&quot; type=&quot;system.configuration.rsaprotectedconfigurationprovider,system.configuration, version=2.0.0.0, <br><br>culture=neutral, publickeytoken=b03f5f7f11d50a3a&quot; /&gt;<br>  &lt;/providers&gt;<br>&lt;/configprotecteddata&gt;<br>注意:这里keycontainername=&quot;hnlaw&quot;和name=&quot;hnlaw&quot;分别表示你的密钥名称;<br><br>3.加密web.config<br>到网站根目录添加一个批处理文件enweb.bat,内容如下:<br>@echo off<br>c:\windows\microsoft.net\framework\v2.0.50727\aspnet_regiis -pef &quot;system.web/identity&quot; &quot;e:\hs  studio\donet2\hnlawyer&quot; -prov <br><br>&quot;hnlaw&quot;<br>  c:\windows\microsoft.net\framework\v2.0.50727\aspnet_regiis -pef &quot;connectionstrings&quot; &quot;e:\hs  studio\donet2\hnlawyer&quot; -prov <br><br>&quot;hnlaw&quot;<br>pause<br>注册上面的的路径和名称!<br>运行后出现成功!<br>4.解密<br>同样到网站根目录添加一个批处理文件deweb.bat,内容如下:<br>@echo off<br>c:\windows\microsoft.net\framework\v2.0.50727\aspnet_regiis -pef &quot;system.web/identity&quot; &quot;e:\hs  studio\donet2\hnlawyer&quot;<br>c:\windows\microsoft.net\framework\v2.0.50727\aspnet_regiis -pdf &quot;connectionstrings&quot; &quot;e:\hs  studio\donet2\hnlawyer&quot;<br>pause<br><br>最后就是要注意:做完后找到c:\documents and settings\all users\application data\microsoft\crypto\rsa\machinekeys目录下,找到生成<br>的密钥文件(可按时间查找),给上network service可读取权限,不然会出现error message from the provider: the rsa key container could <br>not be opened.无法读取<br><br>这样可能会出现,如果没有自己的服务器,没有权限修改machinekeys目录顺便向你推荐一款高速稳定的时代互联智强商务C型 +.CN域名,原价1952元/年,现<br>价只需1588元/年,还免费送域名,CDN网站加速器 送繁简通网络简装版 ，联付宝网上支付，我觉得特值,特向大家推荐!有兴趣的朋友可<br><br>到<a target="_new" href="http://www.now.cn/vhost申请试试">http://www.now.cn/vhost申请试试</a>!     电话：0756-2623717   QQ: 168075865   MSN：north888@now.net.cn<br><br>免费网络电话: <a target="_new" href="http://www.now.cn/customer/moreline.net">http://www.now.cn/customer/moreline.net</a><img src ="http://www.cnitblog.com/willblogs/aggbug/41899.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/willblogs/" target="_blank">陈小小</a> 2008-04-03 15:18 <a href="http://www.cnitblog.com/willblogs/archive/2008/04/03/23025.html#41899#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>