Types of password hashes in php code example
Example 1: hash a password php
password_hash("MySuperSafePassword!", PASSWORD_DEFAULT)
password_verify("MySuperSafePassword!", $hashed_password)
Example 2: php hash password
$host = 'localhost';
$user = 'myUser';
$passwd = 'myPasswd';
$schema = 'mySchema';
$pdo = NULL;
$dsn = 'mysql:host=' . $host . ';dbname=' . $schema;
try
{
$pdo = new PDO($dsn, $user, $passwd);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e)
{
echo 'Database connection failed.';
die();
}