-2

I am developing a web application using netbeans. I am using MySQL as my data base. I want to store the user password in encrypted form in table. and when I will access it using web application they should be in decrypted form. How can I achieve this ? Thanks

Brandon Boone
  • 16,281
  • 4
  • 73
  • 100
adesh
  • 832
  • 4
  • 14
  • 23
  • 1
    Why do you need it decrypted? Isn't a hash sufficent? – juergen d Mar 22 '12 at 12:41
  • To comapre when user enters the password while login i need to check and compare it with it one that is data base. Ya hash will be enough but how to do that? – adesh Mar 22 '12 at 12:46
  • A little search here on SO or on google would have brought up this: http://stackoverflow.com/questions/1289061/best-way-to-use-php-to-encrypt-and-decrypt – Thorsten Dittmar Mar 22 '12 at 12:46
  • juergen d, that is a valid point, but perhaps his vocabulary doesn't yet include the word hash?=) – Shaun Mason Mar 22 '12 at 12:46
  • @adesh: Well, if you create a hash in PHP and compare it to the hash in the database, then this is perfect. Just to get you on the way: When adding a new user to the database, store the user name and a hash of the password. Then, when the user logs in, search for an entry in the database which matches the entered user name and the hash of the password that the user has entered. That way you don't need to store any passwords at all in your database. – Thorsten Dittmar Mar 22 '12 at 12:47
  • @Thorsten Dittmar yup thanx for u quick response. I got your answer. I am also on same track but i dont how to produce hash in java . How can i generate hash of password? – adesh Mar 22 '12 at 12:57
  • @adesh: Again, a quick google for "Java create hash" brought up this: http://stackoverflow.com/questions/415953/generate-md5-hash-in-java – Thorsten Dittmar Mar 22 '12 at 12:59

1 Answers1

1

Try this if hasing is enough

SELECT PASSWORD('mypass') 
juergen d
  • 201,996
  • 37
  • 293
  • 362