Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to recover message from MD5 and Java? [closed]

Tags:

java

hash

md5

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?

like image 249
Prasad Avatar asked Mar 20 '13 10:03

Prasad


1 Answers

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.

like image 181
Andreas Fester Avatar answered Oct 19 '22 18:10

Andreas Fester