-
说一说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;
- }
- }
- }
-
相关阅读:
RabbitMQ 安装
字符串转换
sqlserver 远程链接
力软框架 接口映射的时候不能修改添加接口原因
json串处理2
版本比较,数据库存储
各种分页方法推荐
生成数据库编号重复问题
从统计局抓取2016年最新的全国区县数据!!
“集群和负载均衡”等的通俗解释
-
原文地址:https://www.cnblogs.com/ranran/p/3875278.html
Copyright © 2020-2023
润新知