Contoh-contoh ini dari php.net. Terima kasih kepada Anda, saya juga baru belajar tentang fungsi hashing php yang baru.
Baca dokumentasi php untuk mengetahui tentang kemungkinan dan praktik terbaik:http ://www.php.net/manual/en/function.password-hash.php
Simpan hash sandi:
$options = [
'cost' => 11,
];
// Get the password from post
$passwordFromPost = $_POST['password'];
$hash = password_hash($passwordFromPost, PASSWORD_BCRYPT, $options);
// Now insert it (with login or whatever) into your database, use mysqli or pdo!
Dapatkan hash sandi:
// Get the password from the database and compare it to a variable (for example post)
$passwordFromPost = $_POST['password'];
$hashedPasswordFromDB = ...;
if (password_verify($passwordFromPost, $hashedPasswordFromDB)) {
echo 'Password is valid!';
} else {
echo 'Invalid password.';
}