note 109592 added to function.crypt

From: Date: Tue, 31 Jul 2012 19:28:51 +0000
Subject: note 109592 added to function.crypt
Groups: php.notes 
Request: Send a blank email to php-notes+get-189531@lists.php.net to get a copy of this message
This is my preferred method of random salt generation (above the mt_rand() example below): <? // convBase from http://www.php.net/manual/es/function.base-convert.php#106546 $cost = 10 + (date("Y") - 2010); $salt = '$2a$'.$cost.'$'; $salt .= substr(convBase( raw2hex( openssl_random_pseudo_bytes(16) ), '0123456789abcdef', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ./'), 0, 22); $salt .= '$'; $hash = crypt($_POST['password'], $salt); ?> Cost increases 1 per year, and the salt comes from reliable pseudorandom data. ---- Server IP: 69.147.83.197 Probable Submitter: 132.170.70.116 ---- Manual Page -- http://www.php.net/manual/en/function.crypt.php Edit -- https://master.php.net/note/edit/109592 Del: integrated -- https://master.php.net/note/delete/109592/integrated Del: useless -- https://master.php.net/note/delete/109592/useless Del: bad code -- https://master.php.net/note/delete/109592/bad+code Del: spam -- https://master.php.net/note/delete/109592/spam Del: non-english -- https://master.php.net/note/delete/109592/non-english Del: in docs -- https://master.php.net/note/delete/109592/in+docs Del: other reasons-- https://master.php.net/note/delete/109592 Reject -- https://master.php.net/note/reject/109592 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#189531) next »