加密MD5加密解密方法

md5解密  时间:2021-01-31  阅读:()

asp.net实现MD5加密的方法asp.net自带的md5加密用下面这种方法但这种方法只能加密不能解密。

Respo nse.Write (Forms Authe ntica tion.HashP asswo rdFor Stori ngInC onfig Fi le("要加密的字符串","MD5"));

下面是使用密钥的加密带解密的代码

代码

/*用法protected void Page_Load(object sender, EventArgs e)

{

//加密this.Title=CEncrypt.DesEncrypt("pwd",CEncrypt.Key);this.Title+=CEncrypt.DesDecrypt(this.Title,CEncrypt.Key);

Response.Write(CEncrypt.DesDecrypt("gAYyhdLQunc=",CEncrypt.Key));

}

*/using Syste m;using Syste m. IO;using Syste m.Text;using Syste m.Security.Cryptography;using Syste m.Web;namespaceYD.Common

{

///<summa ry>

///加密码类

///</summa ry>publ icclass CEncrypt

{

///<summa ry>

///加密

///</summa ry>

///<param name="inputString"></param>

///<returns></returns>publ ic static string DesEncrypt(string inputString)

{return DesEncrypt(inputString,Key);

}

///<summa ry>

///解密

///</summa ry>

///<param name="inputString"></param>

///<returns></returns>publ ic static string DesDecrypt(string inputString)

{

return DesDecrypt(inputString,Key);

}

///<summa ry>

///密匙

///</summa ry>private static string Key

{get

{return"hongye10";

}

}

///<summary>

///加密字符串

///注意:密钥必须为 位

///</summa ry>

///<param name="strTe xt">字符串</param>

///<param name="encry ptKey">密钥</param>

///<param name="encry ptKey">返回加密后的字符串</param>publ i c static string DesEncrypt(string inputString, string encryptKey)

{byte[]byKey=nul l;byte[] IV={0x12,0x34,0x56,0x78,0x90,0xAB,0xCD,0xEF};try

{byKey=Syste m.Text.Encoding.UTF8.GetBytes(encryptKey.Subst ring(0,8));

DESCryptoServiceProvider des= new DESCryptoServiceProvider();byte[] inputByteArray=Encoding.UTF8.GetBytes(inputString);

MemoryStream ms= new MemoryStream();

CryptoStream cs = new Crypt oStream(ms, des.CreateEncryptor(byKey, IV),CryptoStreamMode.Write);cs.Write(input ByteArray,0, inputByteArray.Length);cs.FlushFinalBlock();return Convert.ToBase64String(ms.ToArray());

}catch(System.Exception error)

{

//return error.Message;returnnul l;

}

}

///<summa ry>

///解密字符串

///</summa ry>

///<param name="this. input Strin g">加了密的字符串</param>

///<param name="decry ptKey">密钥</param>

///<param name="decry ptKey">返回解密后的字符串</param>publ ic static string DesDecrypt(string inputString, string decryptKey)

{byte[]byKey=nul l;byte[] IV={0x12,0x34,0x56,0x78,0x90,0xAB,0xCD,0xEF};byte[] inputByteArray=new Byte[inputString.Length];try

{byKey=Syste m.Text.Encoding.UTF8.GetBytes(decryptKey.Subst ring(0,8));

DESCryptoServiceProvider des= new DESCryptoServiceProvider();inputByteArray=Convert.FromBase64String(inputString);

MemoryStream ms= new MemoryStream();

CryptoStream cs = new Crypt oStream(ms, des.CreateDecryptor(byKey, IV),CryptoStreamMode.Write);cs.Write(inputByteArray,0, inputByteArray.Length);cs.FlushFinalBlock();

System.Text.Encoding encoding=new System.Text.UTF8Encoding();return encoding.GetString(ms.ToArray());

}catch(System.Exception error)

{

//return error.Message;returnnul l;

}

}

}

}

racknerd:美国大硬盘服务器,$599/月,Ryzen7-3700X/32G内存/120gSSD+192T hdd

racknerd当前对美国犹他州数据中心的大硬盘服务器(存储服务器)进行低价促销,价格跌破眼镜啊。提供AMD和Intel两个选择,默认32G内存,120G SSD系统盘,12个16T HDD做数据盘,接入1Gbps带宽,每个月默认给100T流量,5个IPv4... 官方网站:https://www.racknerd.com 加密数字货币、信用卡、PayPal、支付宝、银联(卡),可以付款! ...

弘速云香港VPSVPS线路有CN2+BGP、CN2 GIA,KVM虚拟化架构,裸金属月付564元

弘速云怎么样?弘速云是创建于2021年的品牌,运营该品牌的公司HOSU LIMITED(中文名称弘速科技有限公司)公司成立于2021年国内公司注册于2019年。HOSU LIMITED主要从事出售香港vps、美国VPS、香港独立服务器、香港站群服务器等,目前在售VPS线路有CN2+BGP、CN2 GIA,该公司旗下产品均采用KVM虚拟化架构。可联系商家代安装iso系统。点击进入:弘速云官方网站地址...

RAKsmart 2021新年新增韩国服务器及香港美国日本VPS半价

RAKsmart 商家我们肯定不算陌生,目前主要的营销客户群肯定是我们。于是在去年的时候有新增很多很多的机房,比如也有测试过的日本、香港、美国机房,这不今年有新增韩国机房(记得去年是不是也有增加过)。且如果没有记错的话,之前VPS主机也有一次磁盘故障的问题。 这不今天有看到商家新增韩国服务器产品,当然目前我还不清楚商家韩国服务器的线路和速度情况,后面我搞一台测试机进行...

md5解密为你推荐
天玑1000plus和骁龙865哪个好麒麟985处理器和天玑1000处理器哪个更好?p图软件哪个好用p图软件哪个好浏览器哪个好用浏览器哪个最好用?电视直播软件哪个好目前最好的电视直播软件是什么?qq空间登录网页版网页版QQ怎么登陆网页qq空间登录网页查看qq空间dns服务器未响应DNS服务器未响应是什么意思?360云盘登录怎样才能登录360云盘!?360云u盘介绍一下360云u盘强生月抛强生月抛隐形眼镜适合什么样的人群佩戴?
shopex虚拟主机 动态ip的vps godaddy域名解析 本网站服务器在美国维护 电影服务器 免费ftp站点 个人域名 泉州电信 域名和空间 美国在线代理服务器 ca187 超级服务器 华为云盘 彩虹云 美国盐湖城 德隆中文网 lamp什么意思 supercache 免费稳定空间 服务器托管价格 更多