我如何解密MD5 [英] How do I decrypt MD5

查看:96
本文介绍了我如何解密MD5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码加密密码:

 public static string GetMD5(string input)
{
using(MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider())
{
byte [] b = System.Text.Encoding.UTF8.GetBytes(input);
b = MD5.ComputeHash(b);
System.Text.StringBuilder sb = new System.Text.StringBuilder();
foreach(b中的字节x)

sb.Append(x.ToString(x2));

返回sb.ToString();
}
}





现在我需要解密它



我尝试了什么:



这是我用来解密密码的代码,但它没有'工作!





 public static string decrypt(string input)
{
尝试
{
var encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
byte [] todecodeByte = Convert.FromBase64String(sData);
int charCount = utf8Decode.GetCharCount(todecodeByte,0,todecodeByte.Length);
char [] decodingChar = new char [charCount];
utf8Decode.GetChars(todecodeByte,0,todecodeByte.Length,decodingChar,0);
string result = new String(decodingChar);
返回结果;
}
catch(exception ex)
{
抛出新异常(base64Decode中的错误+ ex.Message);
}
}

解决方案

你不能。 MD5不是加密。这是一个加密哈希。你不能将哈希解密回原始内容。



你所链接的问题是,由于碰撞,你不能保证文本那个技术提出是生成该哈希的唯一字符串。他们使用表示已知字符串的已知哈希值的字典。它是给我们一个哈希值,我们查找用于生成该哈希的字符串。



冲突是多个输入字符串可以生成的相同的哈希值。 MD5的哈希结果包含如此少量的比特(就哈希而言),碰撞的几率高于使用更多比特的其他哈希值。



想想看它。是否有可能在有限的少量位中表示无限数量的可能字符串?不。





此外,千万不要使用MD5来发送密码! MD5被认为是破碎的,因为猜测产生哈希的字符串所需的计算能力相对较小。


你没有。



可以使用加密哈希进行比较。

如果这是密码,您可以将相同的哈希算法应用于用户条目并查看它是否与保存的内容相匹配。

这不仅适用于MD5,还适用于SHA系列,bCrypt(河豚)和其他常用例程。



至于MD5本身;由于漏洞,加密使用是不安全的。对于其他目的,例如数据完整性和安全性,它仍被认为是安全的。校验和通常不会故意损坏


你不能解密MD5

你提到它的链接只解密你加密的MD5或者某人否则确实

你试试这个字符串

 a23ee3caaeef2cf08e96dde037a74df4 





它不会解密但是一次你加密它将解密数据的原始数据

你可以尝试使用下面的原始数据字符串



amount = 1& currency = USD& amp ;字段= ID,金额,notify_status,货币,时间,参考,notify_id和ID = 3ea3b468735b81e1ef5536d91&安培; notify_id = D0000036689-e915dc40b72c89e4ed55&安培; notify_status =成功&安培;参考= 190404184802PTM03498&安培;时间= 20190404104820&安培;标记= AC12A68A47E1D4569A98688062F9860D0


I have use the following code to encrypt password:

public static string GetMD5(string input)
{
    using(MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider())
    {
        byte[] b = System.Text.Encoding.UTF8.GetBytes(input);
        b = MD5.ComputeHash(b);
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        foreach(byte x in b)

            sb.Append(x.ToString("x2"));

        return sb.ToString();
    }
}



Now I need to decrypt it

What I have tried:

Here is the code I used to decrypt password but it didn't work !


public static string decrypt(string input)
{
    try
    {
        var encoder = new System.Text.UTF8Encoding();
        System.Text.Decoder utf8Decode = encoder.GetDecoder();
        byte[] todecodeByte = Convert.FromBase64String(sData);
        int charCount = utf8Decode.GetCharCount(todecodeByte, 0, todecodeByte.Length);
        char[] decodedChar = new char[charCount];
        utf8Decode.GetChars(todecodeByte, 0, todecodeByte.Length, decodedChar, 0);
        string result = new String(decodedChar);
        return result;
    }
    catch (Exception ex)
    {
        throw new Exception("Error in base64Decode" + ex.Message);
    }
}

解决方案

You can't. MD5 is NOT an encryption. It's a cryptographic hash. You cannot "decrypt" a hash back to the original content.

The problem with what you linked to is that, because of collisions, you cannot guarantee that the text that technique comes up with is the only string that generated that hash. They used a dictionary of known hash values representing known strings. It's a "give us a hash value and we look up the string we used to generate that hash".

A collision is where more than one input string can generate the same hash value. MD5's hash result contains such a small number of bits (as far as hashes go), the chances of a collision is higher than other hashes using more bits.

Think about it. Is it possible to represent an unlimited number of possible strings in a limited, small number of bits? Nope.


Also, NEVER USE MD5 TO HASH PASSWORDS!! MD5 is considered broke because of the relatively small investment in computing power required to guess the string that generated the hash.


You don't.

All that you can do with a cryptographic hash is make a comparison.
If this was a password you would apply the same hashing algorithm to the user entry and see if it matches what is saved.
This not only applies to MD5, but also would apply to the SHA family, bCrypt (blowfish), and other popular routines.

As for MD5 itself; it is not safe for cryptographic use due to vulnerabilities. It is still considered safe for other purposes such as data integrity & checksums which generally are not intentionally corrupted


You Can't decrypt MD5
The link you mentioned it only decrypt MD5 which you encrypt there or someone else did
You try This String

a23ee3caaeef2cf08e96dde037a74df4



It will not decrypt but once you encrypt the original data it will decrypt data
you can try with this original data string as below

amount=1&currency=USD&fields=id,amount,notify_status,currency,time,reference,notify_id&id=3ea3b468735b81e1ef5536d91&notify_id=D0000036689-e915dc40b72c89e4ed55&notify_status=success&reference=190404184802PTM03498&time=20190404104820&token=AC12A68A47E1D4569A98688062F9860D0


这篇关于我如何解密MD5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆