note 105871 added to function.crypt
| From: | eleljrk at gmail dot com | Date: | Wed, 21 Sep 2011 18:23:04 +0000 |
| Subject: | note 105871 added to function.crypt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183331@lists.php.net to get a copy of this message | ||
I've seen many CRYPT_BLOWFISH salt generators, but none REALLY go into the depth of it. This
give you a RANDOM string of 22 characters, the string can contain ANY OF THE ALLOWED characters for
the salt. I wont claim this the best solution, but this is fairly much everything you can do with a
random salt generator.
<?php
public function getSalt() {
$c = explode(" ", ". / a A b B c C d D e E f F g G h H i I j J k K l L m M n N o
O p P q Q r R s S t T u U v V w W x X y Y z Z 0 1 2 3 4 5 6 7 8 9");
$ks = array_rand($c, 22);
$s = "";
foreach($ks as $k) { $s .= $c[$k]; }
return $s;
}
?>
Take note that every allowed character is inside the $c variable, $s is the salt, $ks is for keys to
use in salt and $k is key. There is probably a better and shorter script out there, but this is
solid enough for me.
Have fun with the code.
----
Server IP: 85.19.212.230
Probable Submitter: 62.16.217.90
----
Manual Page -- http://www.php.net/manual/en/function.crypt.php
Edit -- https://master.php.net/note/edit/105871
Del: integrated -- https://master.php.net/note/delete/105871/integrated
Del: useless -- https://master.php.net/note/delete/105871/useless
Del: bad code -- https://master.php.net/note/delete/105871/bad+code
Del: spam -- https://master.php.net/note/delete/105871/spam
Del: non-english -- https://master.php.net/note/delete/105871/non-english
Del: in docs -- https://master.php.net/note/delete/105871/in+docs
Del: other reasons-- https://master.php.net/note/delete/105871
Reject -- https://master.php.net/note/reject/105871
Search -- https://master.php.net/manage/user-notes.php