Schmoopy
04-03-2009, 09:49 PM
Hi, as the title suggests, I have a password that I'm encrypting before it is inserted into the database, do I still need to mysql_real_escape_string it or not?
Here is the code if you're interested:
$salt = substr(sha1(uniqid(rand(), true)), 0 , 10); // Generate a unique 10 character salt
$encpass = sha1($salt . $_POST['password']); // Encrypt password with salt
$pass = $salt . $encpass; // Salt + Encrypted password, salt is prepended so it can be matched when a user logs in
$query = "INSERT INTO admin (user, pass) VALUES ('$user', '$pass')";
Here is the code if you're interested:
$salt = substr(sha1(uniqid(rand(), true)), 0 , 10); // Generate a unique 10 character salt
$encpass = sha1($salt . $_POST['password']); // Encrypt password with salt
$pass = $salt . $encpass; // Salt + Encrypted password, salt is prepended so it can be matched when a user logs in
$query = "INSERT INTO admin (user, pass) VALUES ('$user', '$pass')";