ASP.NET Forums
首页 搜索 用户列表 FAQ 注册 登录  
ASP.NET Forums » ASP.NET Forums 2.0 » 转换到ASP.NET Forums 2.0 » asp.net2.0如何加密数据库联接字符串
  asp.net2.0如何加密数据库联接字符串
帖子发起人: lilcy88   发起时间: 2008-5-12 2:35 PM   回复数: 1
« 上一主题
楼主
  2008-5-12, 2:35 PM
lilcy88 离线,最后访问时间: 5/12/2008 2:35:59 PM lilcy88

无等级

士兵
等级: 士兵
注册: 2008年5月12日
积分: 4
精华: 0
发贴: 2
asp.net2.0如何加密数据库联接字符串
 

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目录顺便向你推荐一款高速稳定的时代互联智强商务C型 +.CN域名,原价1952元/年,现
价只需1588元/年,还免费送域名,CDN网站加速器 送繁简通网络简装版 ,联付宝网上支付,我觉得特值,特向大家推荐!有兴趣的朋友可


http://www.now.cn/vhost申请试试!     电话:0756-2623871   QQ: 168075865   MSN:north888@now.net.cn
全球免费咨询电话 http://www.now.cn/callcenter/call.net?LineName=55


IP 地址: 已登录   来自: 已登录    返回顶部
第 2 楼
  2008-6-27, 2:02 PM
nana001 离线,最后访问时间: 7/17/2008 9:01:33 AM nana001

发帖数前500位

士兵
等级: 士兵
注册: 2008年6月5日
积分: 12
精华: 0
发贴: 11
自己整理的 asp.net 电子书
 
StarASP.NET Cookbook ebook free download
StarASP.NET in a Nutshell ebook free download
StarASP.NET Bible ebook free download
StarSilverlight and ASP.NET Revealed ebook free download
StarProgramming ASP.NET AJAX ebook free download
StarFoundations of ASP.NET AJAX ebook free download
StarASP.NET 2.0 Unleashed ebook free download
StarBeginning Ajax with ASP.NET ebook free download
StarASP.NET 2.0 Revealed ebook free download
StarEssential ASP.NET With Examples in C# ebook free download
StarBeginning ASP.NET 2.0 with C# ebook free download
StarBuilding a Web 2.0 Portal with ASP.NET 3.5 ebook free download
StarHacking the Code: ASP.NET Web Application Security ebook free download
StarC# Developer's Guide to ASP.NET, XML, and ADO.NET ebook free download
StarASP.NET Database Programming Weekend Crash Course ebook free download
StarASP.Net 2.0 Cookbook, 2nd Edition ebook free download
StarASP.NET 2.0 MVP Hacks and Tips ebook free download
StarFoundations of Atlas: Rapid Ajax Development with ASP.NET 2.0 ebook free download
StarPro ASP.NET 3.5 in C# 2008, Second Edition ebook free download
StarReal World ASP.NET: Building a Content Management System ebook free download
StarBeginning Web Development, Silverlight, and ASP.NET AJAX: From Novice to Professional ebook free download
StarBeginning ASP.NET 3.5 in C# 2008 From Novice to Professional, Second Edition ebook free download
StarEnhancing Microsoft Content Management Server with ASP.NET 2.0 ebook free download
StarThe Microsoft Expression Web Developer's Guide to ASP.NET 3.5: Learn to create ASP.NET applications using Visual Web Developer 2008 ebook free download
StarPro ASP.NET for SQL Server: High Performance Data Access for Web Developers ebook free download
StarMicrosoft AJAX Library Essentials Client-side ASP.NET AJAX 1.0 Explained ebook free download


IP 地址: 已登录   来自: 已登录    返回顶部
 第 1 页 总共 1 页 [共有 2 条记录]
ASP.NET Forums » ASP.NET Forums 2.0 » 转换到ASP.NET Forums 2.0 » asp.net2.0如何加密数据库联接字符串

友情链接: hiDotNet官方论坛 | hiDotNet知识库 | 其它友情链接

Asp.Net Forums version: 2.5.2725
(C)Copyright 2004-2007, hiDotNet.com. All Rights Reserved.
意见反馈 | 关于我们

Powered by Community Server :: Forums 中文本地化: hiDotNet.com