password hash generator php code example
Example 1: hash a password php
password_hash("MySuperSafePassword!", PASSWORD_DEFAULT)
password_verify("MySuperSafePassword!", $hashed_password)
Example 2: online password generator in php
<?php
function randomPassword() {
$alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
$pass = array();
$alphaLength = strlen($alphabet) - 1;
for ($i = 0; $i < 8; $i++) {
$n = rand(0, $alphaLength);
$pass[] = $alphabet[$n];
}
return implode($pass);
}
echo randomPassword();
?>
Example 3: password hash php
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
password_verify($password, $hashed_password);
Example 4: php hash password
$password = 'my secret password';
$hash = password_hash($password, PASSWORD_DEFAULT);
Example 5: password_hash
<?php
$password = 'idkWhatToUse';
$hashedPassword= password_hash($password, PASSWORD_DEFAULT);
?>
Example 6: php hash password
$password = 'my secret password';
$options = ['cost' => 12];
$hash = password_hash($password, PASSWORD_DEFAULT, $options);