4

I have stored (and encoded) an email password. I have used PasswordEncoder (Spring security).

passwordEncoder.encode(password);

Now I need to decode it in order to use it in javax mail. (the password is used to connect to the email provider(yahoo, gmail, etc).
Is there a way to decode this password?

4
  • 3
    There isn't... Passwords are encrypted using a one way algorithm, it isn't the password that is stored but a calculated hash of the password. So there isn't a way to recover the actual password. As it should... Commented Sep 14, 2015 at 7:30
  • Ok, thanks. Does Spring provides a password encode/decode api? or do you know a robust java password encode/decode api? Commented Sep 14, 2015 at 7:34
  • you can use jasypt, but being able to decrypt passwords is a possible security breach. Commented Sep 14, 2015 at 7:36
  • A must read for password encryption/decryption is jasypt.org/howtoencryptuserpasswords.html Commented Sep 14, 2015 at 7:47

1 Answer 1

7

PasswordEncoder interface support only encoding and matching which is the best way to deal with password as others too have suggested. You can use StandardPBEStringEncryptor provided by Jasypt library as this library had transparent integration with Spring Security. Else you can roll out your own using Java Cryptography Extension's Password Based Encryption (PBE) however before trying what you want to achieve with regards to password encryption you must definitely read this.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.