PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.19.3
GiveWP – Donation Plugin and Fundraising Platform v2.19.3
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / vendor / fakerphp / faker / src / Faker / Provider / Uuid.php
Uuid.php
59 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Faker\Provider;
4
5 class Uuid extends Base
6 {
7 /**
8 * Generate name based md5 UUID (version 3).
9 * @example '7e57d004-2b97-0e7a-b45f-5387367791cd'
10 */
11 public static function uuid()
12 {
13 // fix for compatibility with 32bit architecture; each mt_rand call is restricted to 32bit
14 // two such calls will cause 64bits of randomness regardless of architecture
15 $seed = mt_rand(0, 2147483647) . '#' . mt_rand(0, 2147483647);
16
17 // Hash the seed and convert to a byte array
18 $val = md5($seed, true);
19 $byte = array_values(unpack('C16', $val));
20
21 // extract fields from byte array
22 $tLo = ($byte[0] << 24) | ($byte[1] << 16) | ($byte[2] << 8) | $byte[3];
23 $tMi = ($byte[4] << 8) | $byte[5];
24 $tHi = ($byte[6] << 8) | $byte[7];
25 $csLo = $byte[9];
26 $csHi = $byte[8] & 0x3f | (1 << 7);
27
28 // correct byte order for big edian architecture
29 if (pack('L', 0x6162797A) == pack('N', 0x6162797A)) {
30 $tLo = (($tLo & 0x000000ff) << 24) | (($tLo & 0x0000ff00) << 8)
31 | (($tLo & 0x00ff0000) >> 8) | (($tLo & 0xff000000) >> 24);
32 $tMi = (($tMi & 0x00ff) << 8) | (($tMi & 0xff00) >> 8);
33 $tHi = (($tHi & 0x00ff) << 8) | (($tHi & 0xff00) >> 8);
34 }
35
36 // apply version number
37 $tHi &= 0x0fff;
38 $tHi |= (3 << 12);
39
40 // cast to string
41 $uuid = sprintf(
42 '%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x',
43 $tLo,
44 $tMi,
45 $tHi,
46 $csHi,
47 $csLo,
48 $byte[10],
49 $byte[11],
50 $byte[12],
51 $byte[13],
52 $byte[14],
53 $byte[15]
54 );
55
56 return $uuid;
57 }
58 }
59