note 103338 added to function.crypt
| From: | varnav at osu1 dot php dot net | Date: | Fri, 08 Apr 2011 01:31:52 +0000 |
| Subject: | note 103338 added to function.crypt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-178618@lists.php.net to get a copy of this message | ||
Here is what I use to generate secure passwords. Based on what kaminski offered:
<?php
$salt = '$2a$10$'.substr(str_replace('+', '.',
base64_encode(pack('N4', mt_rand(), mt_rand(), mt_rand(), mt_rand()))), 0, 22) .
'$';
$hashed_password = crypt($password, $salt);
?>
This thing uses Blowfish algorithm. It takes 0.12 seconds on my server to generate this password,
making brute-force attack really ineffective. You may play with that "cost" value,
changing it from 10 to something. Incrementing this value by 1 roughly doubles calculation time.
----
Server IP: 69.147.83.197
Probable Submitter: 98.224.239.142
----
Manual Page -- http://www.php.net/manual/en/function.crypt.php
Edit -- https://master.php.net/note/edit/103338
Del: integrated -- https://master.php.net/note/delete/103338/integrated
Del: useless -- https://master.php.net/note/delete/103338/useless
Del: bad code -- https://master.php.net/note/delete/103338/bad+code
Del: spam -- https://master.php.net/note/delete/103338/spam
Del: non-english -- https://master.php.net/note/delete/103338/non-english
Del: in docs -- https://master.php.net/note/delete/103338/in+docs
Del: other reasons-- https://master.php.net/note/delete/103338
Reject -- https://master.php.net/note/reject/103338
Search -- https://master.php.net/manage/user-notes.php