Aug-30-2022, 11:15 PM
Don't know for Python, but PHP has password_hash($password, PASSWORD_DEFAULT) for saving the password of a new user, as yet unregistered user, to a database table.
This creates a 255 character string, I believe. Anyway, the encrypted password is very long and complicated.
Then, when a user logs on, you get the user's ordinary password, like: John, and use password_verify() to check it against the encrypted password stored in the database.
Python must have a very similar system. Except you are not working with webpages and SQL, which should make things easier.
This creates a 255 character string, I believe. Anyway, the encrypted password is very long and complicated.
Quote://encrypt password using password_hash()
$password = password_hash($password, PASSWORD_DEFAULT);
//insert new user to our database
Then, when a user logs on, you get the user's ordinary password, like: John, and use password_verify() to check it against the encrypted password stored in the database.
Quote:// first check the password. If incorrect, bale out
//validate the password with $user[password]
if(!password_verify($password, $user['password'])){
$_SESSION['loginerror'] = '密码不对的 Incorrect password!!';
header('location: index.php');
exit();
}
Python must have a very similar system. Except you are not working with webpages and SQL, which should make things easier.