I heard it is bad to store passwords in plain text in a database so i'm looking for a nice safe way to store pass works. i have done some research and have a working example.
$cost =10;
$salt =strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.');
$salt = sprintf("$2a$%02d$",$cost).$salt;
$hash = crypt($password,$salt);
$hash is the final string that is saved into the database. To get the hashed password i have //$password = pass from the DB $enteredpass = pass from the login $hash = crypt($password,$enterdPass ); if($enterdPass == $hash) // pass entered is correct
I'm not looking for the best ever hashing just something that is good enough to put out on the internet as a small company or something