09-18-2024, 03:54 AM
(This post was last modified: 09-18-2024, 03:55 AM by Progromatic Admin.)
password_hash
(PHP 5 >= 5.5.0, PHP 7, PHP 8)
password_hash — Creates a password hash
Description
Example password_hash() example
The above example will output something similar to:
(PHP 5 >= 5.5.0, PHP 7, PHP 8)
password_verify — Verifies that a password matches a hash
Description
Example # password_verify() example
This is a simplified example; it is recommended to rehash a correct password if necessary; see password_needs_rehash() for an example.
(PHP 5 >= 5.5.0, PHP 7, PHP 8)
password_hash — Creates a password hash
Description
Quote:password_hash(#[\SensitiveParameter] string $password, string|int|null $algo, array $options = []): stringpassword_hash() creates a new password hash using a strong one-way hashing algorithm.
Example password_hash() example
PHP Code:
<?php
/**
* We just want to hash our password using the current DEFAULT algorithm.
* This is presently BCRYPT, and will produce a 60 character result.
*
* Beware that DEFAULT may change over time, so you would want to prepare
* By allowing your storage to expand past 60 characters (255 would be good)
*/
echo password_hash("rasmuslerdorf", PASSWORD_DEFAULT);
?>
Quote:$2y$10$.vGA1O9wmRjrwAVXD98HNOgsNpDczlqm3Jq7KnEd1rVAGv3Fykk1apassword_verify
(PHP 5 >= 5.5.0, PHP 7, PHP 8)
password_verify — Verifies that a password matches a hash
Description
PHP Code:
password_verify(#[\SensitiveParameter] string $password, string $hash): bool
Example # password_verify() example
This is a simplified example; it is recommended to rehash a correct password if necessary; see password_needs_rehash() for an example.
PHP Code:
<?php
// See the password_hash() example to see where this came from.
$hash = '$2y$10$.vGA1O9wmRjrwAVXD98HNOgsNpDczlqm3Jq7KnEd1rVAGv3Fykk1a';
if (password_verify('rasmuslerdorf', $hash)) {
echo 'Password is valid!';
} else {
echo 'Invalid password.';
}
?>
Dev Abdulrahman Abdulwahab
I'm Web and Mobile Developer
Forum Admin and Store Admin
I'm Web and Mobile Developer
Forum Admin and Store Admin