惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - kary

VS 2005 Web Deployment Projects GridView绑定数据源,无记录时表头也显示的一种解决方法 Web Deployment Projects with Visual Studio 2005 快速排序与二分查找算法Javascript版本 - kary - 博客园 随页面移动的浮动广告代码 - kary - 博客园 MSDN转:自定义实体类简介 aspnet2.0 Menu控件上传到服务器小问题 ASP.NET2.0的快速入门站点 AJAX开发简略 - kary 用人之道(二)-- 何管理软件开发团队 转:用人之道(一)-- 如何组建软件开发队伍 袁峰写的开发之路 雅虎公司C#笔试题 转:产品开发模式管理网站开发 Windows IIS 6安全保护贴—URL授权全攻略! Access库的小问题 要做互联星空的SP接口,一点头绪都没有 windows server 2003 出错提示"请求的资源在使用中"解决方案 针对SQL INJECTION的SQL SERVER安全设置初级篇
asp.net2.0如何加密数据库联接字符串 - kary - 博客园
kary · 2006-05-19 · via 博客园 - kary

asp.net2.0如何加密数据库联接字符串
在asp.net2.0中,发布网站时,加密web.config,这样可以有效保证数据库用户和密码安全,其步骤如下:

1.添加密钥
执行:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pc "hnlaw" -exp
其中"hnlaw"为密钥名称

2.添加web.config节点
在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
 到网站根目录添加一个批处理文件enweb.bat,内容如下:
 @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
注册上面的的路径和名称!
运行后出现成功!
4.解密
同样到网站根目录添加一个批处理文件deweb.bat,内容如下:
 @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目录下,找到生成

的密钥文件(可按时间查找),给上network service可读取权限,不然会出现Error message from the provider: The RSA key container could

not be opened.
无法读取

这样可能会出现,如果没有自己的服务器,没有权限修改MachineKeys目录,不知道还有其它解决办法,希望大家共享一下:)