note 22106 deleted from function.uniqid by philip
| From: | philip@php.net | Date: | Sun, 13 Oct 2002 02:51:10 +0000 |
| Subject: | note 22106 deleted from function.uniqid by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-37994@lists.php.net to get a copy of this message | ||
I just was plaing with this and other functions
and came up with this.
May be it will help some body paranoid.
function uniq_id()
{
if (!$GLOBALS["IHaveCalledSrandBefore"]++) {
srand((double) microtime() * 1234567892524324);
}
$id = md5(
uniqid(
rand(
bcmul(
microtime(),
microtime(),
rand(1,123)
),
bcdiv(
rand(0,93583746),
rand(1,357409823),
rand(1,123)
)
),
bcpow( microtime(), getmypid(), rand(microtime(),getmyinode()) )
)
);
Return $id;
}
function suniq_id()
{
$seed =
uniq_id()
.microtime()
.uniq_id()
.microtime()
.uniq_id()
.microtime()
.uniq_id();
$id = md5(base64_encode($seed));
Return $id;
}
I hope you understand what to do with this.
It is a bit slow but on my laptop to generate 1000 keys
of the suniq_id function took
about 80 seconds.