This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Security and the fly likes how to save password in encrypted/Decrypted format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "how to save password in encrypted/Decrypted format" Watch "how to save password in encrypted/Decrypted format" New topic
Author

how to save password in encrypted/Decrypted format

raj jaiswal
Ranch Hand

Joined: Nov 25, 2008
Posts: 56
Hi


I want to save password in encrypted/Decrypted format in database.How to do that..
Please some help me to do this.



Thanks
Rajjaiswal
MCA SCJP1.6
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41054
    
  43
Encrypting a password merely transform the problem of protecting passwords to the problem of protecting the encryption key - which is not substantially different.

What one usually does instead is to hash (or digest) passwords using an algorithm like SHA-2 (or SHA-256, as it's called in the Java world), thus ensuring that passwords can never be recovered.


Ping & DNS - my free Android networking tools app
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Ulf Dittmer wrote:an algorithm like SHA-2 (or SHA-256, as it's called in the Java world)


SHA2 denotes the family SHA-256, SHA-384 and SHA-512 and not just SHA-256. All are available in the JRE.


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
raj jaiswal
Ranch Hand

Joined: Nov 25, 2008
Posts: 56
hi


Actually i dont know any things about SHA-256 .Please give some example so that i can understand better.

thanks
Mathieu Fortin
Greenhorn

Joined: Jan 29, 2011
Posts: 16
Usually you want one way encryption with passwords. Look into the java.security.MessageDigest class.

Some pseudo code:


Mathieu
http://simpleadn.blogspot.com
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to save password in encrypted/Decrypted format
 
Similar Threads
how to encrypt the text
Need Help With Caesar Shift
Encryption/decryption using core java and then insert into database
J2C Authentication Data
password in memory