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

}

}

}

}

NameCheap黑色星期五和网络礼拜一

如果我们较早关注NameCheap商家的朋友应该记得前几年商家黑色星期五和网络星期一的时候大促采用的闪购活动,每一个小时轮番变化一次促销活动而且限量的。那时候会导致拥挤官网打不开迟缓的问题。从去年开始,包括今年,NameCheap商家比较直接的告诉你黑色星期五和网络星期一为期6天的活动。没有给你限量的活动,只有限时六天,这个是到11月29日。如果我们有需要新注册、转入域名的可以参加,优惠力度还是比...

日本CN2、香港CTG(150元/月) E5 2650 16G内存 20M CN2带宽 1T硬盘

提速啦简单介绍下提速啦 是成立于2012年的IDC老兵 长期以来是很多入门级IDC用户的必选商家 便宜 稳定 廉价 是你创业分销的不二之选,目前市场上很多的商家都是从提速啦拿货然后去分销的。提速啦最新物理机活动 爆炸便宜的香港CN2物理服务器 和 日本CN2物理服务器香港CTG E5 2650 16G内存 20M CN2带宽 1T硬盘 150元/月日本CN2 E5 2650 16G内存 20M C...

弘速云20.8元/月 ,香港云服务器 2核 1g 10M

弘速云元旦活动本公司所销售的弹性云服务器、虚拟专用服务器(VPS)、虚拟主机等涉及网站接入服务的云产品由具备相关资质的第三方合作服务商提供官方网站:https://www.hosuyun.com公司名:弘速科技有限公司香港沙田直营机房采用CTGNET高速回国线路弹性款8折起优惠码:hosu1-1 测试ip:69.165.77.50​地区CPU内存硬盘带宽价格购买地址香港沙田2-8核1-16G20-...

md5解密为你推荐
软银支付雅虎在05年就被阿里巴巴收购了,为什么现在又会出现马云收回支付宝产权,雅虎和软银不高兴的情况呢?麒麟820和980哪个好麒麟980跟骁龙855哪个好一点?录屏软件哪个好有什么好用的游戏录屏软件推荐吗?机械表和石英表哪个好买石英表还是机械表好啊炒股软件哪个好炒股软件真的那么好用吗?苹果手机助手哪个好iphone有什么比较好用的软件!游戏盒子哪个好游戏盒子哪个好?尼康和佳能单反哪个好尼康和佳能哪个好啊?云盘哪个好网盘哪个好用?google广告申请怎样才能申请google广告
虚拟主机mysql 济南域名注册 vps论坛 荷兰vps 132邮箱 东莞电信局 flashfxp怎么用 tier 免费ftp站点 牛人与腾讯客服对话 dd444 hkg 静态空间 傲盾官网 华为云服务登录 美国独立日 web服务器是什么 全能空间 华为k3 lamp什么意思 更多