23 if (function_exists(
'random_bytes'))
25 $data = random_bytes(16);
27 elseif (function_exists(
'openssl_random_pseudo_bytes'))
29 $data = openssl_random_pseudo_bytes(16);
32 $data = uniqid(
'',
true);
36 $data[6] = chr(ord($data[6]) & 0x0f | 0x40);
39 $data[8] = chr(ord($data[8]) & 0x3f | 0x80);
41 return vsprintf(
'%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));