Re: mcrypt_create_iv - why so slow?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Nathan Nobbe
> Interesting, using MCRYPT_DEV_URANDOM instead of MCRYPT_DEV_RANDOM
> seems practically instantaneous. Still [raises] the question though,
> any idea what's holding up the show w/ MCRYPT_DEV_RANDOM?

/dev/random is a high quality entropy source and requires more time to
generate output, as it has to retrieve random stuff from keyboard interrupts,
mouse interrupts, and other sources, and make sure it's got *really* random
bits.  /dev/urandom will just throw out a pile of pseudo-random bits of
potentially lower quality immediately.  You can see that by doing "time dd
if=/dev/random of=/dev/null bs=16k count=5" and repeating the same command
with /dev/urandom.  1.312 seconds vs. 0.019 seconds here.

Not much to do with PHP, though, just the way the Linux kernel people did
things.  /dev/urandom is probably the way to go for most normal random data
needs.

-- 
Matt G / Dances With Crows
The Crow202 Blog:  http://crow202.org/wordpress/
There is no Darkness in Eternity/But only Light too dim for us to see


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux