加密web.config的方法分享
1、打开记事本,然后将狼蚁网站SEO优化的代码复制到一个新文件中。
<%@ Page Language="C#" %>
<%
Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name);
%>
保存 my.aspx 到你的web目录 ,运行一下窗体显示 “ NT AUTHORITY\NETWORK SERVICE ”。成功!
2、(关键一步)运行cmd,执行以下
asp_regiis -pa "NetFrameworkConfigurationKey" "NT AUTHORITY\NETWORK SERVICE"
说明:注册默认的 RsaProtectedConfigurationProvider 的RSA 密钥容器,
NetFrameworkConfigurationKey 是 RsaProtectedConfigurationProvider 的默认provider。 成功!
3、现在,可以加密web.config ,运行:
加密:asp_regiis -pe "connectionStrings" -app "/Myweb"
说明:"connectionStrings" 是要加密的节,"/Myweb"是的web目录
解密:asp_regiis -pd "connectionStrings" -app "/Myweb"
成功!
4、这样就可以在程序里调用了(不用解密, 哈哈
):
...
string connstr= ConfigurationManager.ConnectionStrings["myConnstr"].ConnectionString.ToString();
...
同样的,也可以用创建自己的RSA 密钥容器,如下:
(1)、创建 "MyKeys" 密钥容器,运行:asp_regiis -pc "MyKeys" -exp
(2)、在web.config里加入以下:
<protectedData>
<providers>
<add name="MyProvider"
type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0. 0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d0a3a,
processorArchitecture=MSIL"
keyContainerName="MyKeys"
useMachineContainer="true" />
</providers>
</protectedData>
保存。
(3)、授予帐户对计算机级别的 "MyKeys" RSA 密钥容器的访问权限,运行:
asp_regiis -pa "MyKeys" "NT AUTHORITY\NETWORK SERVICE"
(4)、现在,可以加密web.config ,运行:
加密:asp_regiis -pe "connectionStrings" -app "/Myweb"-prov "MyProvider"
说明:"connectionStrings" 是要加密的节,"/Myweb"是的web目录,"MyProvider" 自己密钥容器
解密:asp_regiis -pd "connectionStrings" -app "/Myweb"-prov "MyProvider"
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程