note 84517 added to function.mcrypt-module-open
| From: | ash at osu1 dot php dot net | Date: | Thu, 17 Jul 2008 10:07:53 +0000 |
| Subject: | note 84517 added to function.mcrypt-module-open | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-141610@lists.php.net to get a copy of this message | ||
A slight improvement of dinamic's function to create a key:
I think the weak point is that capitals are always used in the same part of the string. The
following code capitalizes random characters of the string, making the key less predictable:
<?php
$key = substr($key1, 0, $ks/2) . substr($key2, (round(strlen($key2) / 2)), $ks/2);
$key = substr($key.$key1.$key2.$key1,0,$ks);
$buffer = str_split($key);
$limit = count($buffer)-1;
srand((float)microtime() * 1000000);
$end = rand(0, $limit);
$a = 0;
// replace random chars with capitals
while ($a < $end) {
list($usec, $sec) = explode(' ', microtime());
$seed = ((float)$sec) + ((float) $usec * 100000);
mt_srand($seed);
$index = mt_rand(0,$limit);
$buffer[$index] = strtoupper($buffer[$index]);
$a++;
}
$key = join('', $buffer);
?>
----
Server IP: 217.160.72.57
Probable Submitter: 91.19.68.174
----
Manual Page -- http://www.php.net/manual/en/function.mcrypt-module-open.php
Edit -- https://master.php.net/note/edit/84517
Del: integrated -- https://master.php.net/note/delete/84517/integrated
Del: useless -- https://master.php.net/note/delete/84517/useless
Del: bad code -- https://master.php.net/note/delete/84517/bad+code
Del: spam -- https://master.php.net/note/delete/84517/spam
Del: non-english -- https://master.php.net/note/delete/84517/non-english
Del: in docs -- https://master.php.net/note/delete/84517/in+docs
Del: other reasons-- https://master.php.net/note/delete/84517
Reject -- https://master.php.net/note/reject/84517
Search -- https://master.php.net/manage/user-notes.php