note 103441 added to function.crypt

From: Date: Wed, 13 Apr 2011 17:15:47 +0000
Subject: note 103441 added to function.crypt
Groups: php.notes 
Request: Send a blank email to php-notes+get-178803@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: 192.41.42.26 Probable Submitter: 98.224.239.142 ---- Manual Page -- http://www.php.net/manual/en/function.crypt.php Edit -- https://master.php.net/note/edit/103441 Del: integrated -- https://master.php.net/note/delete/103441/integrated Del: useless -- https://master.php.net/note/delete/103441/useless Del: bad code -- https://master.php.net/note/delete/103441/bad+code Del: spam -- https://master.php.net/note/delete/103441/spam Del: non-english -- https://master.php.net/note/delete/103441/non-english Del: in docs -- https://master.php.net/note/delete/103441/in+docs Del: other reasons-- https://master.php.net/note/delete/103441 Reject -- https://master.php.net/note/reject/103441 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#178803) next »