php - Any reason not to use bcrypt on email addresses? -


login form i'm working on right uses user email address , password login. thinking, there reason why shouldn't want use bcrypt on email addresses as:

$email_hash = password_hash($email, password_default); 

i know it's intended passwords, what? should work on emails well... if email used login, shouldn't hashed/salted password? know isn't standard practice, never understood why.

i don't need know user's email addresses. mean, it's not i'm gonna chat them. maybe when user gets banned should inform them email, why bother informing outlaws in first place.

you need email address lookup user record.

typically this:

function create_account(email, password) {     var pwhash = password_hash($password, password_bcrypt);     // insert users values ($email, $pwhash); }  function login(email, password) {     // select pwhash users email = $email;     return password_verify($password, $pwhash); // true or false } 

password_hash($email) return different value because bcrypt includes salt in hash.

from wikipedia:

for example, [bcrypt hash] $2a$10$n9qo8uloickgx2zmrzomyeijzagcfl7p92ldgxad68ljzdl17lhwy specifies cost parameter of 10, indicating 210 key expansion rounds. salt n9qo8uloickgx2zmrzomye , resulting hash ijzagcfl7p92ldgxad68ljzdl17lhwy.

or php docs:

note password_hash() returns algorithm, cost , salt part of returned hash. therefore, information that's needed verify hash included in it. allows verify function verify hash without needing separate storage salt or algorithm information.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -