• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving Password value

 
Deepa Balasubramanayam
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody,
I inserted password like this:
PreparedStatement stat1 =
con.prepareStatement("INSERT INTO TS_TEST "+
"VALUES (?,PASSWORD(?)) ");
stat1.setString(1,name);
stat1.setString(2,password);
stat1.executeUpdate();
The above statement worked fine and the password was encrypted.For ex: I entered 'abc' as my password and it was stored as '7cd2b5942be28759'.
The problem is , when I try to select the PASSWORD colomn I see only the encrpted value '7cd2b5942be28759'. How can I retrieve the real value from the table'abc' for password comparision.
Note:
I am using mysql database
Thanks
Deepa
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't. The PASSWORD command is usually a one-way hash function that cannot be undone. The advantage here is that if anyone breaks into your database, getting the password field does not compromise your users.
You validate the password, pass the password entered through the same function and compare the two values.
DOM
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic