1
0
mirror of https://github.com/fzaninotto/Faker.git synced 2025-03-22 00:09:59 +01:00

simplified uuid generation, fixed comments

This commit is contained in:
Maik Penz 2013-02-05 17:44:26 +01:00
parent 965367c8c4
commit dc94119d7b

View File

@ -14,12 +14,9 @@ class Uuid extends \Faker\Provider\Base
// Hash the seed and convert to a byte array
$val = md5($seed, true);
$byte = array();
foreach (unpack('C16', $val) as $tmpKey => $tmpVal) {
$byte[$tmpKey-1] = $tmpVal;
}
$byte = array_values(unpack('C16', $val));
// b2f
// extract fields from byte array
$tLo = ($byte[0] << 24) | ($byte[1] << 16) | ($byte[2] << 8) | $byte[3];
$tMi = ($byte[4] << 8) | $byte[5];
$tHi = ($byte[6] << 8) | $byte[7];
@ -34,7 +31,7 @@ class Uuid extends \Faker\Provider\Base
$tHi = (($tHi & 0x00ff) << 8) | (($tHi & 0xff00) >> 8);
}
// apply version
// apply version number
$tHi &= 0x0fff;
$tHi |= (3 << 12);