Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Encryption/decryption using core java and then insert into database  RSS feed

 
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.
 
Rancher
Posts: 42975
76
  • 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.
 
Sheriff
Posts: 21423
94
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!