asp.net2.0如何加密数据库联接字符串
来源:互联网 发布:汽车进口贸易额数据 编辑:程序博客网 时间:2024/05/06 11:59
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目录,不知道还有其它解决办法,希望大家共享一下:)
<script type="text/javascript"><!--google_ad_client = "pub-3488423754339938";google_alternate_color = "EDF8FF";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";//2007-04-08: 0082google_ad_channel = "7436923838";google_color_border = "EDF8FF";google_color_bg = "EDF8FF";google_color_link = "000000";google_color_text = "000000";google_color_url = "008000";//--></script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>- asp.net2.0如何加密数据库联接字符串
- asp.net2.0如何加密数据库联接字符串
- asp.net2.0如何加密数据库联接字符串
- asp.net2.0如何加密数据库联接字符串
- asp.net2.0如何加密数据库联接字符串
- asp.net2.0如何加密数据库联接字符串 (转)
- asp.net2.0如何加密数据库联接字符串
- asp.net2.0如何加密数据库联接字符串
- asp.net2.0加密数据库连接字符串
- ASP.NET2.0瞎记-加密链接字符串
- ASP.NET2.0瞎记-加密链接字符串
- Asp.net2.0MD5加密
- 数据库联接字符串大全
- 数据库联接字符串
- 数据库开发字符串联接
- 数据库联接字符串大全
- 数据库联接字符串
- asp.net2.0数据库操作
- 二级日语语法总汇(4)
- grep的新体会
- AIS(自动识别系统)介绍
- 双链表的创建、插入、删除
- 再谈突破TCP-IP过滤/防火墙进入内网(icmp篇)
- asp.net2.0如何加密数据库联接字符串
- 一道面试题目
- 基数排序
- 用ASP.NET加密口令
- 程序员的 好习惯
- RFC3261相关学习[问题]
- 二叉树的创建、遍历、深度、叶子节点个数
- 二叉排序树生成查找
- 浅谈DotNet 保护中的字符串加密技术