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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With