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 加密数据库连接字符串的更多相关文章

  1. Enterprise Library 中加密数据库连接字符串

    看了SHY520写的关于Data Access Application Block的文章,写得不错,忽略了一点就是如何去加密数据库连接字符串,这儿我简单的介绍一下.我们知道,在Enterprise L ...

  2. EF--Codefirst 加密数据库连接字符串

    http://www.tuicool.com/articles/QvYbEn 一.EF,CodeFirst加密SQL连接符 public LifeHelpContext() : base(" ...

  3. 创建自己的RSA密钥来保护web.config 加密数据库连接字符串

    通过创建自己的RSA密钥来保护web.config1创建RSA密钥:C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis - ...

  4. Winform 加密连接字符串“未能提供RsaProtectedConfigurationProvider加密,对象已存在”的解决方案

    当一台机器已安装软件,并有新用户需要使用此软件时提示“未能提供RsaProtectedConfigurationProvider加密,对象已存在”. 这是因为加密模式是用户模式,需要运行以下脚本添加新 ...

  5. web config数据库连接字符串加密

    ASP.NET web.config中,数据库连接字符串的加密与解密 ASP.NET web.config中,数据库连接字符串的加密与解密. 开始--->运行,输入cmd,接着输入以下内容 加密 ...

  6. c#Winform程序调用app.config文件配置数据库连接字符串 SQL Server文章目录 浅谈SQL Server中统计对于查询的影响 有关索引的DMV SQL Server中的执行引擎入门 【译】表变量和临时表的比较 对于表列数据类型选择的一点思考 SQL Server复制入门(一)----复制简介 操作系统中的进程与线程

    c#Winform程序调用app.config文件配置数据库连接字符串 你新建winform项目的时候,会有一个app.config的配置文件,写在里面的<connectionStrings n ...

  7. ASP.NET加密和解密数据库连接字符串

    大家知道,在应用程序中进行数据库操作需要连接字符串,而如果没有连接字符串,我们就无法在应用程序中完成检索数据,创建数据等一系列的数据库操作.当有人想要获取你程序中的数据库信息,他首先看到的可能会是We ...

  8. EntLib 自动数据库连接字符串加密

    const string provider = "RsaProtectedConfigurationProvider"; Configuration config = null; ...

  9. 关于IBatisNet的配置文件中数据库连接字符串加密处理

    我们通常在IBatisNet配置文件 properties.config 加入数据库连接字符串.数据库连接字符串直接放在里面,没有被加密,很不安全.如果我们把 properties.config 文件 ...

随机推荐

  1. protobuf配置与使用

    Protobuf配置与安装 1 安装与配置 1.protobuf是google公司提出的数据存储格式,详细介绍可以参考:https://code.google.com/p/protobuf/ 2.下载 ...

  2. HDUOJ---2642Stars(二维树状数组)

    Stars Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/65536 K (Java/Others)Total Submi ...

  3. hdu4135容斥原理 组合遍历

    容斥原理实现的关键在于:组合遍历,即如何遍历2^n种组合. 容斥原理的三种写法: DFS 队列数组 位数组 #include<stdio.h> #include<iostream&g ...

  4. go 学习 ---数据类型

    25个关键字 程序声明:import, package 程序实体声明和定义:chan, const, func, interface, map, struct, type, var 程序流程控制:go ...

  5. C++:借助tinyxml2读取XML文件

    // XMLT01.cpp : 定义控制台应用程序的入口点.//#include "stdafx.h"#include <iostream>#include " ...

  6. android 自定义ViewSwipeBackHelper,实现左滑结束Activity

     https://github.com/Jude95/SwipeBackHelper Git上看到一个基于SwipeBackLayout的实现,可以让我们在使用过程中在不使用物理返回键的情况下舍去了返 ...

  7. Linux时间子系统(六) POSIX timer

    一.前言 在用户空间接口函数文档中,我们描述了和POSIX timer相关的操作,主要包括创建一个timer.设定timer.获取timer的状态.获取timer overrun的信息.删除timer ...

  8. hibernate,动态更新,插入 dynamic-insert,dynamic-update 我有话要说 ---稍后整理

    http://dreamzhong.iteye.com/blog/1207377 http://blog.csdn.net/hsuxu/article/details/8108326 @org.hib ...

  9. 如何理解Latency和Throughput: 吞吐量和延迟

    Latency,中文译作延迟.Throughput,中文译作吞吐量.它们是衡量软件系统的最常见的两个指标. 延迟一般包括单向延迟(One-way Latency)和往返延迟(Round Trip La ...

  10. InnoDB Master Thread I/O Rate详解

    一.innodb 在刷盘时要面对的问题: 1.对于innodb 的master thread 这个线程来说,它会在后台执行许多的任务,这些任务大多数都是与IO操作相关的, 比如“刷新脏页到磁盘”.“合 ...