-
说一说ASP.NET web.config 加密及解密方法 (代码)
-
-
- public class ProtectHelper
- {
-
-
-
-
-
-
- public static string UnProtectSection(string pToDecrypt, string sKey)
- {
- byte[] inputByteArray = Convert.FromBase64String(pToDecrypt);
- using (DESCryptoServiceProvider des = new DESCryptoServiceProvider())
- {
- des.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
- des.IV = ASCIIEncoding.ASCII.GetBytes(sKey);
- System.IO.MemoryStream ms = new System.IO.MemoryStream();
- using (CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write))
- {
- cs.Write(inputByteArray, 0, inputByteArray.Length);
- cs.FlushFinalBlock();
- cs.Close();
- }
- string str = Encoding.UTF8.GetString(ms.ToArray());
- ms.Close();
- return str;
- }
- }
-
-
-
-
-
-
-
- public static string ProtectSection(string pToEncrypt, string sKey)
- {
- using (DESCryptoServiceProvider des = new DESCryptoServiceProvider())
- {
- byte[] inputByteArray = Encoding.UTF8.GetBytes(pToEncrypt);
- des.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
- des.IV = ASCIIEncoding.ASCII.GetBytes(sKey);
- System.IO.MemoryStream ms = new System.IO.MemoryStream();
- using (CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write))
- {
- cs.Write(inputByteArray, 0, inputByteArray.Length);
- cs.FlushFinalBlock();
- cs.Close();
- }
- string str = Convert.ToBase64String(ms.ToArray());
- ms.Close();
- return str;
- }
- }
- }
-
相关阅读:
linux之卸载软件
linux之挂载硬盘
windows MySQL 5+ 服务手动安装
深刻理解Python中的元类(metaclass)
Python_cmd的各种实现方法及优劣(subprocess.Popen, os.system和commands.getstatusoutput)
WSGI、flup、fastcgi、web.py的关系
Windows下python环境变量配置
External file changes sync may be slow: Project files cannot be watched (are they under network mount?)
as。 对象和数组
为什么for不能有序遍历数组的所有元素?(Array的设计原理)
-
原文地址:https://www.cnblogs.com/ranran/p/3875278.html
Copyright © 2020-2023
润新知