Is it possible to recover message from MD5 and Jav

2019-01-07 20:59发布

问题:

I have the following code.

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;            
}

Now I want to convert it back to the original string. Is it possible?

回答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.



标签: java hash md5