Originally posted by: dude8604
I'm working on a signup php scipt that stores passwords. I want them to be encrypted. Is there a way to encrypt the passwords in the database and allow a login script to have access to it? Thanks.
When writing the password to the database (using an INSERT or maybe an UPDATE statement), use the MySQL
PASSWORD function to encrypt that text. An example of usage:
INSERT INTO table VALUES
('username', PASSWORD('password'), 'someone@somewhere.com');
Simple, neh? Remember though that this is one-way encryption, there is no way to retrieve to clear text version of the password once it's been written. At that point, to for example verify if a user is logging in with the correct password, take a password in, run the MySQL PASSWORD function on what the user has supplied and compare that encrypted text to the encrypted password saved to the database. There you go, your password verification scheme.