Verify a password in PHP

<?php $correct= password_hash("Correct password", PASSWORD_DEFAULT); $wrong= password_hash("Wrong password", PASSWORD_DEFAULT); echo password_verify("Correct password", $correct) ? "Correct Password" : "Wrong Password"; echo "<br>"; echo password_verify("example of wrong password", $wrong) ? "Correct Password!" : "Wrong Password"; ?>
Password verify will check if a plain string will match a string that has been created with password_hash().

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.