1

I encrypted password using MD5 and inserted them to MySQL database. But, How can I decrypt that password to the original and place them in a jTextField.

H Athukorala
  • 739
  • 11
  • 32

2 Answers2

3

MD5 is supposed to be one-directional function so in theory there is no way to decrypt it... instead of decrypting it - compare encrypted valued for password validation, but you will not be able to show the original password to the user.

BTW I said supposed as md5 is quite weak for security (and can be broken)

Maciej
  • 1,954
  • 10
  • 14
2

MD5 is a hashing function, not encryption, this means is irreversible. Thus can't be decrypted. What you can do is compare the resulting hash of a known input against another hash.

Depending on what you are trying to do, you should consider using another hashing function, since:

The MD5 algorithm is a widely used hash function producing a 128-bit hash value. Although MD5 was initially designed to be used as a cryptographic hash function, it has been found to suffer from extensive vulnerabilities. It can still be used as a checksum to verify data integrity, but only against unintentional corruption.

If you are interested in alternatives check here on how to store passwords.

lloiacono
  • 4,714
  • 2
  • 30
  • 46