File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes how to encrypt & decrypt password Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to encrypt & decrypt password" Watch "how to encrypt & decrypt password" New topic

how to encrypt & decrypt password

Praveen Reddy
Ranch Hand

Joined: Jul 12, 2006
Posts: 51
Hi Everyone

please help me in encrypting and decrypting passwords while sending to database and retriving from database.

if possible please give me detail explanation.

Thanks in advance
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You'll most likely want to use the classes in the javax.crypto package. This link should give you some ideas.

Consultant, Sima Solutions
Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
For password, I'd suggest not to encrypt/decrypt it. Rather, it is better to store the MD5/hash value of the password in the database and only verify the MD5/hash of any user supplied password against the database. In this way, you never risk exposing the raw password to anyone including the database admin. Also, you don't have to worry about managing the encryption key which is very troublesome.

BTW, Tomcat 5 already have built-in support for storing hashed password if you use its database realm.
Praveen Reddy
Ranch Hand

Joined: Jul 12, 2006
Posts: 51
thanks a lot it solved my problem
I agree. Here's the link:
subject: how to encrypt & decrypt password
It's not a secret anymore!