是否有可能从MD5和Java恢复的消息? [关闭](Is it possible to reco

2019-07-22 02:26发布

我有下面的代码。

String plaintext = "HelloWorld";
MessageDigest m = MessageDigest.getInstance("MD5");
m.reset();
m.update(plaintext.getBytes());
byte[] digest = m.digest();
BigInteger bigInt = new BigInteger(1,digest);
String hashtext = bigInt.toString(16); 

// Now we need to zero pad it if you actually want the full 32 chars.
while(hashtext.length() < 32 ){
    hashtext = "0"+hashtext;            
}

现在我想将其转换回原始字符串。 可能吗?

Answer 1:

I have tried this. Now I want to convert it back to Original string.

This is not possible with MD5. It is a one-way hash function.

In order to be able to encrypt and decrypt, you need to use an encryption/decryption algorithm like AES.

See Java™ Cryptography Architecture (JCA) Reference Guide for more information.



文章来源: Is it possible to recover message from MD5 and Java? [closed]
标签: java hash md5