Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Encryption/decryption using core java and then insert into database

 
Vinod Vinu
Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i want to use encryption like RSA algorithm in java.
For e.g - during a registeration process in my application, whenever the user inputs a password, i want to encryp that password and pushed that encrypted key into database.
During login process, user will enter his/her username and password, this password will be matched with the decrypted password(encrypted in db) and once validated, it can go through.

Now i have no idea about it. Kindly provide me how to do that using core java ?

Thanks in advance.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The proper approach is not to encrypt passwords, but to hash (or digest) them using an algorithm like SHA-2 (or SHA-256/SHA-384/SHA-512, as it is known in the Java world). That way you can be sure that a password is never exposed. See the SecurityFaq for more information.
 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
javax.crypto.Cipher for encrypting
java.security.MessageDigest for hashing
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic