2024-08-01 12:48:29 +01:00
|
|
|
<?php
|
2024-08-01 17:00:18 +01:00
|
|
|
/* VanillaUUID v1.0.1 by abbieoverflight.
|
2024-08-01 12:48:29 +01:00
|
|
|
* Licenced under the EUPLv1.2.
|
|
|
|
* https://git.colean.cc/threeoh6000/vanillauuid */
|
|
|
|
function randomLongHex() {
|
|
|
|
$byt = random_bytes(64);
|
|
|
|
return bin2hex($byt);
|
|
|
|
}
|
|
|
|
|
|
|
|
function genUuid4() {
|
|
|
|
$template = randomLongHex();
|
2024-08-01 17:00:18 +01:00
|
|
|
|
|
|
|
$ri = random_int(0b1000, 0b1011);
|
|
|
|
$encoded_byt = dechex((int)$ri);
|
|
|
|
$buildup = substr($template, 0, 8) . "-" . substr($template, 8, 4) . "-4" . substr($template, 13, 3) . "-" . $encoded_byt . substr($template, 17, 3) . "-" . substr($template, 20, 12);
|
2024-08-01 12:48:29 +01:00
|
|
|
|
|
|
|
return $buildup;
|
|
|
|
}
|
|
|
|
|
|
|
|
function nilUuid() {
|
|
|
|
return "00000000-0000-0000-0000-000000000000";
|
|
|
|
}
|
|
|
|
|
|
|
|
function omniUuid() {
|
|
|
|
return "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF";
|
|
|
|
}
|
|
|
|
?>
|