How to validate the password in PHP and MYSQL -


this question has answer here:

i have found article code below on web want use learn more php/mysql...

$username = 'admin'; $password = 'gf45_gdf#4hg';  $salt = hash('sha256', uniqid(mt_rand(), true) . 'a random string go here' . strtolower($username));  $hash = $salt . $password;  ( $i = 0; $i < 100000; $i ++ ) {      $hash = hash('sha256', $hash); }  $hash = $salt . $hash; 

how validate password in php when user wants log in?

you run exact same procedure , see if results match.

this general procedure seeing if sumbitted password stores matched password.

  • you create function hashes , stores known password, , typically salts well
  • you store in database
  • when user submits password login, run through exact same hashing , salting algorithm, , see if resulting hash matches hash stored in database

you should consider using bcrypt instead: how use bcrypt hashing passwords in php?


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -