加密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;

}

}

}

}

织梦DEDECMS即将授权收费和维权模式 站长应对的几个方法

这两天在站长群里看到不少有使用DEDECMS织梦程序的朋友比较着急,因为前两天有看到来自DEDECMS,我们熟悉的织梦程序官方发布的公告,将会在10月25日开始全面商业用途的使用DEDECMS内容管理程序的会采用授权收费模式,如果我们有在个人或者企业商业用途的,需要联系且得到授权才可以使用,否则后面会通过维权的方式。对于这个事情,我们可能有些站长经历过,比如字体、图片的版权。以及有一些国内的CMS...

美得云(20元)香港特价将军澳CTG+CN2云服务器

美得云成立于2021年,是一家云产品管理服务商(cloud)专业提供云计算服务、DDOS防护、网络安全服务、国内海外数据中心托管租用等业务、20000+用户的选择,43800+小时稳定运行香港特价将军澳CTG+CN2云服务器、采用高端CPU 优质CN2路线 SDD硬盘。香港CTG+CN22核2G3M20G数据盘25元点击购买香港CTG+CN2​2核2G5M30G数据盘39元点击购买香港CTG+CN...

tmhhost:暑假快乐,全高端线路,VPS直接8折,200G高防,美国gia日本软银韩国cn2香港cn2大带宽

tmhhost为2021年暑假开启了全场大促销,全部都是高端线路的VPS,速度快有保障。美国洛杉矶CN2 GIA+200G高防、洛杉矶三网CN2 GIA、洛杉矶CERA机房CN2 GIA,日本软银(100M带宽)、香港BGP直连200M带宽、香港三网CN2 GIA、韩国双向CN2。本次活动结束于8月31日。官方网站:https://www.tmhhost.com8折优惠码:TMH-SUMMER日本...

md5解密为你推荐
软银孙正义如何看待中国的首富马云?如何看待日本软银孙正义腾讯空间首页qq空间主页怎么每个都看不见华为p40和mate30哪个好荣耀30pro和华为P40哪个好?机械表和石英表哪个好石英表和机械表哪个好尼康和佳能单反哪个好佳能和尼康哪个好空间登录器qq空间登录不了怎么办dns服务器地址DNS服务地址360云查杀360安全卫士中的木马云查杀有用吗?360云盘论坛360云盘最大多少G广东联通网络传真免费网络传真
krypt warez dns是什么 5折 ibox官网 ftp教程 河南m值兑换 qq云端 服务器合租 免费mysql数据库 raid10 万网空间管理 www789 免费ftp lamp怎么读 google搜索打不开 ncp是什么 apache启动失败 2016黑色星期五 cdn免备案空间 更多