Winform RsaProtectedConfigurationProvider 加密数据库连接字符串
private static string _strProvider = "RsaProtectedConfigurationProvider";
/// <summary>
/// 提供加密的驱动
/// </summary>
public string Provider
{
get { return _strProvider; }
set { _strProvider = value; }
}
/// <summary>
///
/// </summary>
public ConfigSection() { }
/// <summary>
/// 加密配置文件节点
/// </summary>
/// <param name="strSectionName">节点名称</param>
public static void EncryptConfigSection(string strSectionName)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
ConfigurationSection section = config.GetSection(strSectionName);
if (section != null && !section.IsReadOnly() && !section.ElementInformation.IsLocked && !section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection(_strProvider);
section.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
ConfigurationManager.RefreshSection(strSectionName);
}
}
/// <summary>
/// 解密配置文件节点
/// </summary>
/// <param name="strSectionName">节点名称</param>
public static void DecryptConfigSection(string strSectionName)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
ConfigurationSection section = config.GetSection(strSectionName);
if (section != null && !section.IsReadOnly() && !section.ElementInformation.IsLocked && section.SectionInformation.IsProtected)
{
section.SectionInformation.UnprotectSection();
section.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
ConfigurationManager.RefreshSection(strSectionName);
}
}
Winform RsaProtectedConfigurationProvider 加密数据库连接字符串的更多相关文章
- Enterprise Library 中加密数据库连接字符串
看了SHY520写的关于Data Access Application Block的文章,写得不错,忽略了一点就是如何去加密数据库连接字符串,这儿我简单的介绍一下.我们知道,在Enterprise L ...
- EF--Codefirst 加密数据库连接字符串
http://www.tuicool.com/articles/QvYbEn 一.EF,CodeFirst加密SQL连接符 public LifeHelpContext() : base(" ...
- 创建自己的RSA密钥来保护web.config 加密数据库连接字符串
通过创建自己的RSA密钥来保护web.config1创建RSA密钥:C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis - ...
- Winform 加密连接字符串“未能提供RsaProtectedConfigurationProvider加密,对象已存在”的解决方案
当一台机器已安装软件,并有新用户需要使用此软件时提示“未能提供RsaProtectedConfigurationProvider加密,对象已存在”. 这是因为加密模式是用户模式,需要运行以下脚本添加新 ...
- web config数据库连接字符串加密
ASP.NET web.config中,数据库连接字符串的加密与解密 ASP.NET web.config中,数据库连接字符串的加密与解密. 开始--->运行,输入cmd,接着输入以下内容 加密 ...
- c#Winform程序调用app.config文件配置数据库连接字符串 SQL Server文章目录 浅谈SQL Server中统计对于查询的影响 有关索引的DMV SQL Server中的执行引擎入门 【译】表变量和临时表的比较 对于表列数据类型选择的一点思考 SQL Server复制入门(一)----复制简介 操作系统中的进程与线程
c#Winform程序调用app.config文件配置数据库连接字符串 你新建winform项目的时候,会有一个app.config的配置文件,写在里面的<connectionStrings n ...
- ASP.NET加密和解密数据库连接字符串
大家知道,在应用程序中进行数据库操作需要连接字符串,而如果没有连接字符串,我们就无法在应用程序中完成检索数据,创建数据等一系列的数据库操作.当有人想要获取你程序中的数据库信息,他首先看到的可能会是We ...
- EntLib 自动数据库连接字符串加密
const string provider = "RsaProtectedConfigurationProvider"; Configuration config = null; ...
- 关于IBatisNet的配置文件中数据库连接字符串加密处理
我们通常在IBatisNet配置文件 properties.config 加入数据库连接字符串.数据库连接字符串直接放在里面,没有被加密,很不安全.如果我们把 properties.config 文件 ...
随机推荐
- LeetCode(35):Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negativ ...
- set 容器 的全解(转)
1.关于set C++ STL 之所以得到广泛的赞誉,也被很多人使用,不只是提供了像vector, string, list等方便的容器,更重要的是STL封装了许多复杂的数据结构算法和大量常用数据结构 ...
- 【js与jquery】jquery循环滚动新闻
2.html代码: <h3>最新动态</h3> <div class="scrollNews" > <ul> <li>& ...
- java开发_eclipse导出为war文件,热部署到tomcat运行总结[转]
在Myeclipse中,我们很容易做到这一步:把一个web项目生成war文件 其实在eclipse中,实现这样的功能,也是很简单的. 下面就看一下是怎样操作的吧! 新建一个web项目: 取名为:ecl ...
- OAF_OAF Framework状态分析(概念)
20150706 Created By BaoXinjian
- 怎样用vb设置文件夹权限?解决办法
原文链接: http://www.reader8.cn/jiaocheng/20120201/1805958.html 怎样用vb设置文件夹权限?现在做的程序需要对win2000和win2003的文件 ...
- 安装composer slim(php web api micro services)
1. 安装php7 2. 下载 https://getcomposer.org/composer.phar 3. 开启ssh, 在 php.ini中.extension=C:\Program File ...
- Linux上添加新硬盘的实例介绍
在Linux上添加新硬盘的实例讲解,有需要的朋友可以看看. 系统:Redhat AS3 UP3硬盘:scsi注意:# 表示是root用户执行的命令 [root@cncmail data1]# fdis ...
- [svc][op]ssh交互yes问题解决-expect
Expect是Unix系统中用来进行自动化控制和测试的软件工具C67默认未安装:使用需要安装: yum install expect -ywhich expect #查看安装路径 核心命令: [roo ...
- 【Android】8.2 动态选择和设置主题
分类:C#.Android.VS2015: 创建日期:2016-02-17 一.简介 除了通过Theme指定主题外,还可以在程序运行时动态指定并应用主题. 二.示例-ch0802ThemeDemo 1 ...