Wednesday 27 July 2011

Java-Encryption



When your application has log in form or registration form,you may need to save the passwords of the users to the db.The best practice when saving passwords is using java encryption.There are some implicit algorithms used for encryption and the following code uses the SHA algorithm.



So,now the encrypted values can be put to the db and the same can be used while validating the user entered password  with out any decryption.I mean follow the same encryption process and validate the entry.

More info on Cryptographic Hash functions can be found here.

Cheers..... :-)

3 comments:

  1. For case insensitive data base...this will come in more handy...since this encryption is case sensitive.

    ReplyDelete
  2. Where are you providing public key to encrypt???
    If there is no key, is it that anyone can decrypt it?

    ReplyDelete
  3. SHA-1 is one-way ticket. The way you validate password matches is to do SHA-1 the entered password and see if the hashes match.

    Thanks!!

    ReplyDelete