One way of using /dev/urandom
is the function uiniqid which should fit your needs.
However, if you need true random numbers you should better use /dev/random
as /dev/urandom
is still a pseudo random number generator which use /dev/random
for seed values.
Accessing the random number stream is not that hard.
<?php
$r = unpack('v*', fread(fopen('/dev/random', 'r'),16));
$uuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
$r[1], $r[2], $r[3], $r[4] & 0x0fff | 0x4000,
$r[5] & 0x3fff | 0x8000, $r[6], $r[7], $r[8]);
?>
Obviously this is not production code.