Hello i want to encrypt or hash some data and put them on the database. Which is more secure encryption or hash and how i can do this?
thank you very much for your help

5 Years
Discussion Span
Last Post by jalpesh_007

Thank you for the reply. How i can use AES but the key that is used to encrypt and decrypt will be always the same for a user?
Thank you very much


you can see the following link to get more idea about your question



What you want is a one way hash rather than encryption, decryption. You store the hashed password in the database. When you get the password at login time, you hash it and compare it to the version stored in the database. There is absolutely no way to derive the real password from the persisted version.

This is very easy. Use the java.security.MessageDigest class, http://java.sun.com/j2se/1.3/docs/api/java/security/MessageDigest.html. It doesn't really matter which algorithm you choose, MD5 or SHA, but there's plenty of documents on Google comparing the two.


I did the hash for the password but now i want to encrypt some informations that i put in cookie. So i need two way encryption so i can encrypt and decrypt it
Thank you very much i will check the links


i think you have to follow the link through which you can get more ideas about which algorithm to use..AES or MD5....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.