How to send the password already with the hash to the database

-4

How could I do to send a hashed password to my database?

  

Code

$PDO = db_connect();
$sql = "INSERT INTO users(nome, login, password, email,linkfb) VALUES(:name, :login, :senha, :email, :linkfb)";
$stmt = $PDO->prepare($sql);
$stmt->bindParam(':name', $name);
$stmt->bindParam(':login', $login);
$stmt->bindParam(':senha', $senha);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':linkfb', $linkfb);
$senha = isset($_POST['senha']) ? $_POST['senha'] : null;
    
asked by anonymous 29.09.2018 / 19:48

1 answer

0

hash

$PDO = db_connect();
$sql = "INSERT INTO users(nome, login, password, email,linkfb) VALUES(:name, :login, :senha, :email, :linkfb)";
$senha = hash('ripemd160', $senha);
$stmt = $PDO->prepare($sql);
$stmt->bindParam(':name', $name);
$stmt->bindParam(':login', $login);
$stmt->bindParam(':senha', $senha);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':linkfb', $linkfb);
$stmt->execute();

or

$senha = password_hash($senha, PASSWORD_BCRYPT, 10);

validation

$senha = isset($_POST['senha']) ? hash('ripemd160', $_POST['senha']) : hash('ripemd160', 'null');

If you use hash to 'ripemd160' and what you will use to validate the password again when you need it

    
29.09.2018 / 20:03