管理员
|
楼主#
更多
发布于:2011-12-11 16:47
| | | | MD5加密解密,MD516位加密,MD532位加密。MD5简介 MD5:Message Digest Algorithm MD5(中文名为消息摘要算法第五版)为计算机安全领域广泛使用的一种散列函数,用以提供消息的完整性保护。 1991年,Rivest开发出技术上更为趋近成熟的md5算法。它在MD4的基础上增加了"安全-带子"(safety-belts)的概念。虽然MD5比MD4稍微慢一些,但却更为安全。这个算法很明显的由四个和MD4设计有少许不同的步骤组成。在MD5算法中,信息-摘要的大小和填充的必要条件与MD4完全相同。Den boer和Bosselaers曾发现MD5算法中的假冲突(pseudo-collisions),但除此之外就没有其他被发现的加密后结果了。 Van oorschot和Wiener曾经考虑过一个在散列中暴力搜寻冲突的函数(brute-force hash function),而且他们猜测一个被设计专门用来搜索MD5冲突的机器(这台机器在1994年的制造成本大约是一百万美元)可以平均每24天就找到一个冲突。但单从1991年到2001年这10年间,竟没有出现替代MD5算法的MD6或被叫做其他什么名字的新算法这一点,我们就可以看出这个瑕疵并没有太多的影响MD5的安全性。上面所有这些都不足以成为MD5的在实际应用中的问题。并且,由于MD5算法的使用不需要支付任何版权费用的,所以在一般的情况下(非绝密应用领域。但即便是应用在绝密领域内,MD5也不失为一种非常优秀的中间技术),MD5怎么都应该算得上是非常安全的了。 MD5用的是哈希函数,在计算机网络中应用较多的不可逆加密算法有RSA公司发明的MD5算法和由美国国家技术标准研究所建议的安全散列算法SHA。 MD5为不可逆的加密算法,所以目前还没有解密被MD5加密过的密文,唯一的办法即“穷举法”,俗称“暴力破解”。MD5加密MD5 32位加密方法: string str = "jcuiawhqekhkjasd"; string MD5Str = FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5");MD5 16位加密方法: string str = "jcuiawhqekhkjasd"; string MD5Str = FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").Substring(8, 16);‍ MD5解密 解密我写的是单线程的,所以程序在密码对比的时候,如果字典比较大会卡住。大家可以写多线程。 原理很简单,就是把字典中的明文密码逐行读取加密为MD5,再匹配与需要解密的MD5是否一致,如果不一致继续下一条,如果一致则跳出。publicvoid LoadPassWord() { string time = DateTime.Now.Millisecond.ToString(); this.progressBar1.Maximum = 100; this.progressBar1.Value = 0; this.progressBar1.Step = 5; StreamReader str = newStreamReader(txtURL.Text); rtbBox.Text = str.ReadToEnd(); StreamReader strs = newStreamReader(txtURL.Text); for (int i = 0; i < rtbBox.Lines.Length; i++) { //System.Threading.Thread.Sleep(1000);//暂停1秒 int count = rtbBox.Lines.Length; if (rtbBox.Lines.Length > 1000) { this.progressBar1.Maximum = count; this.progressBar1.Step = 2; if (progressBar1.Value != count) { progressBar1.Value += progressBar1.Step;//让进度条增加一次 } } else { if (progressBar1.Value != 100) { progressBar1.Value += progressBar1.Step;//让进度条增加一次 } } txtPassWord16J.Text = strs.ReadLine(); if (txtMD516J.Text.Length == 16) { if (txtMD516J.Text.ToLower() == FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtPassWord16J.Text, "MD5").Substring(8, 16).ToLower()) { if (progressBar1.Maximum != count) { progressBar1.Value = 100; string Etime = DateTime.Now.Millisecond.ToString(); double Otime = Convert.ToDouble(time) - Convert.ToDouble(Etime); MessageBox.Show("完成破解!明文: "+ txtPassWord16J.Text + "; 总共耗时: "+ Otime.ToString() + " 单位:毫秒","暴力提示",MessageBoxButtons.OK,MessageBoxIcon.Information); return; } else { progressBar1.Value = count; string Etime = DateTime.Now.Millisecond.ToString(); double Otime = Convert.ToDouble(time) - Convert.ToDouble(Etime); MessageBox.Show("完成破解!明文: "+ txtPassWord16J.Text + "; 总共耗时: "+ Otime.ToString() + " 单位:毫秒", "暴力提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else { txtPassWord16J.Text = "未知"; } } elseif(txtMD516J.Text.Length == 32) { if (txtMD516J.Text.ToLower() == FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtPassWord16J.Text, "MD5").ToLower()) { if (progressBar1.Maximum != count) { progressBar1.Value = 100; string Etime = DateTime.Now.Millisecond.ToString(); double Otime = Convert.ToDouble(time) - Convert.ToDouble(Etime); MessageBox.Show("完成破解!明文: "+ txtPassWord16J.Text + "; 总共耗时: "+ Otime.ToString() + " 单位:毫秒", "暴力提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { progressBar1.Value = count; string Etime = DateTime.Now.Millisecond.ToString(); double Otime = Convert.ToDouble(time) - Convert.ToDouble(Etime); MessageBox.Show("完成破解!明文: "+ txtPassWord16J.Text + "; 总共耗时: "+ Otime.ToString() + " 单位:毫秒", "暴力提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else { txtPassWord16J.Text = "未知"; } } } }‍‍‍ 由于百度字数限制,所以只能贴出部分代码。我已经把整个demo打包,有兴趣的朋友可以下载。MD5加密解密,MD516位加密,MD532位加密。C#MD5加密解密下载地址:‍ http://www.jessstudio.com/software/download/md5.rar‍‍‍‍‍ 欢迎提出其中的不足,欢迎留言,欢迎转载。。。MD5加密解密,MD516位加密,MD532位加密。C#MD5加密解密
| | | | |
|