mysql - Replacing SHA1 with BCRYPT -


this question has answer here:

i have been looking replacing sha1 encryption of passwords possibly bcrypt or similar, , cant seem find step-by-step, easy follow tutorial implementing this. did quick tutorial on youtube produced following code:

$username = 'myusername'; $password = 'pa55w0rd';  $str  = substr($username, 0, 6); $salt = '$2a$12$ru8e3fsi9rskh3v2'.$str.'$'; $pass = crypt($password, $salt);  echo $salt . '<br>' . $pass; 

and when run code in browser, output:

$2a$12$ru8e3fsi9rskh3v2myuser$ $2a$12$ru8e3fsi9rskh3v2myuseemsot1badlfs/ncqhx5ag2q953uqp.tu 

question 1:

am correct in assuming both strings generated user, , both strings required stored in, example, users table columns "salt" , "pass"?

question 2:

why part of username visible within salt , pass? normal, or there additional step need take eliminate happening?

question 3:

is approach hashing passwords more secure md5 , sha1, or there better approach should using?

any suggestions appreciated..

i'd recommend using php's new password_hash , password_verify functions.

as don't have php >= 5.5.0, there's php implementation adds support upcoming functions older versions of php.

more info: https://gist.github.com/nikic/3707231


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -