Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Q&A
RevCMS BCRYPT
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="MayoMayn" data-source="post: 400710" data-attributes="member: 71840"><p>[PHP]</p><p>password_hash($password, PASSWORD_BCRYPT, ['cost' => 12]);</p><p>[/PHP]</p><p></p><p>I'd just stick with the ordinary PASSWORD_DEFAULT and without the array, unless you're providing your own hashing.</p><p></p><p>And for validation, just use:</p><p>[PHP]</p><p>password_verify(</p><p> $pass, // unencrypted password that the user has entered in the form</p><p> $dbpass // the hashed password in the db column</p><p>);</p><p>[/PHP]</p><p></p><p>[SPOILER]</p><p>If you get incorrect false responses from password_verify when manually including the hash variable (eg. for testing) and you know it should be correct, make sure you are enclosing the hash variable in single quotes (') and not double quotes (").</p><p></p><p>PHP parses anything that starts with a $ inside double quotes as a variable:</p><p></p><p>[PHP]</p><p>// this will result in 'Invalid Password' as the hash is parsed into 3 variables of</p><p>// $2y, $07 and $BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq</p><p>// due to it being enclosed inside double quotes</p><p>$hash ="$2y$07$BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq";</p><p></p><p>// this will result in 'Password is valid' as variables are not parsed inside single quotes</p><p>$hash ='$2y$07$BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq';</p><p></p><p>if (password_verify('rasmuslerdorf',$hash)) {</p><p> echo 'Password is valid!';</p><p>} else {</p><p> echo 'Invalid password.';</p><p>}</p><p>[/PHP]</p><p>[/SPOILER]</p></blockquote><p></p>
[QUOTE="MayoMayn, post: 400710, member: 71840"] [PHP] password_hash($password, PASSWORD_BCRYPT, ['cost' => 12]); [/PHP] I'd just stick with the ordinary PASSWORD_DEFAULT and without the array, unless you're providing your own hashing. And for validation, just use: [PHP] password_verify( $pass, // unencrypted password that the user has entered in the form $dbpass // the hashed password in the db column ); [/PHP] [SPOILER] If you get incorrect false responses from password_verify when manually including the hash variable (eg. for testing) and you know it should be correct, make sure you are enclosing the hash variable in single quotes (') and not double quotes ("). PHP parses anything that starts with a $ inside double quotes as a variable: [PHP] // this will result in 'Invalid Password' as the hash is parsed into 3 variables of // $2y, $07 and $BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq // due to it being enclosed inside double quotes $hash ="$2y$07$BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq"; // this will result in 'Password is valid' as variables are not parsed inside single quotes $hash ='$2y$07$BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq'; if (password_verify('rasmuslerdorf',$hash)) { echo 'Password is valid!'; } else { echo 'Invalid password.'; } [/PHP] [/SPOILER] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
RevCMS BCRYPT
Top