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

}

}

}

}

hostkvm:美国VPS,三网强制CU-VIP线路,$5/月,1G内存/1核/15gSSD/500g流量

hostkvm在2021年3月新上线洛杉矶新VPS业务,强制三网接入中国联通优化线路,是当前中美之间性价比最高、最火热的线路之一,性价比高、速度非常好,接近联通AS9929和电信AS4809的效果,带宽充裕,晚高峰也不爆炸。 官方网站:https://hostkvm.com 全场优惠码:2021(全场通用八折,终身码,长期) 美国 US-Plan0【三网联通优化线路】 内存:1G CPU:...

建站选择网站域名和IP主机地址之间关系和注意要点

今天中午的时候有网友联系到在选择网站域名建站和主机的时候问到域名和IP地址有没有关联,或者需要注意的问题。毕竟我们在需要建站的时候,我们需要选择网站域名和主机,而主机有虚拟主机,包括共享和独立IP,同时还有云服务器、独立服务器、站群服务器等形式。通过这篇文章,简单的梳理关于网站域名和IP之间的关系。第一、什么是域名所谓网站域名,就是我们看到的类似"www.laozuo.org",我们可以通过直接记...

企鹅小屋6折年付240元起,美国CN2 GIA VPS促销,独享CPU,三网回程CN2 GIA

企鹅小屋怎么样?企鹅小屋最近针对自己的美国cn2 gia套餐推出了2个优惠码:月付7折和年付6折,独享CPU,100%性能,三网回程CN2 GIA网络,100Mbps峰值带宽,用完优惠码1G内存套餐是年付240元,线路方面三网回程CN2 GIA。如果新购IP不能正常使用,请在开通时间60分钟内工单VPS技术部门更换正常IP;特价主机不支持退款。点击进入:企鹅小屋官网地址企鹅小屋优惠码:年付6折优惠...

md5解密为你推荐
软银赛富请问如何投资私募股权?在哪买?qq空间首页QQ空间的主页316不锈钢和304哪个好304跟316的不锈钢材质有什么区别304和316不锈钢哪个好304与316用哪个好?电脑管家和360哪个好电脑管家和360安全卫士哪个好辽宁联通网上营业厅中国联通网上营业厅固定电话费查询电信10000宽带测速怎样测试电信宽带的网速? 771212willyunlee最近开了007系列的第20部电影《择日再死》,看不懂剧情,不知说什么。谁能说给我听,谢谢。电信dns服务器地址电信宽带的DNS服务地址是多少360云盘网页版网页版360云盘打不开,求助!
vps论坛 ipage bbr kddi 免费网站监控 2017年黑色星期五 150邮箱 anylink 免费个人空间 vip购优惠 能外链的相册 申请免费空间和域名 华为云盘 yundun 空间登陆首页 国外在线代理服务器 浙江服务器 阿里dns 江苏双线 杭州电信宽带 更多