Jump to content

Php Mysql Password Encryption/decryption


Guest bbperis335
 Share

Recommended Posts

Guest bbperis335

Hi all, Trying to display a password which is stored in a mysql db using sha1 to encrypt it,Is there a way to do that ? I can currently display the password but only in its encrypted form Here is my sql code to store the password as encrypted:INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('$e', SHA1('$p'), '$fn', '$ln', '$a', NOW() )";Here is my select statement code to display to users in the users table:SELECT last_name, first_name, pass, DATE_FORMAT(registration_date, '%M %d, %Y') AS dr, user_id FROM users ORDER BY registration_date ASC";Here is my respective html to handle the rest of the job:<td align="left">'. $row['last_name']. '</td><td align="left">'. $row['first_name']. '</td><td align="left">'. $row['pass']. '</td><td align="left">'. $row['dr']. '</td>appreciate you help !

Link to comment
Share on other sites

You're not supposed to unencrypt it. In fact, "encrypted" is technically incorrect; The password is "hashed". An encryption can be unencrypted, while hashing is irreversible.The point in hashing the passwords is so that they can't be unencrypted and that way nobody can steal them even if they get access to the database.The only reason you need a password is to confirm that the person logging in is authorized to use the account. If you want to check that the password they typed in is correct, hash the password before comparing it to the password that's in the database.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...