17 lines
448 B
PHP
17 lines
448 B
PHP
|
<?php
|
||
|
/* VanillaUUID by abbieoverflight.
|
||
|
* Licenced under the EUPLv1.2.
|
||
|
* https://git.colean.cc/threeoh6000/vanillauuid */
|
||
|
function randomLongHex() {
|
||
|
$byt = random_bytes(64);
|
||
|
return bin2hex($byt);
|
||
|
}
|
||
|
|
||
|
function uuid4() {
|
||
|
$template = randomLongHex();
|
||
|
$buildup = substr($template, 0, 8) . "-" . substr($template, 8, 4) . "-4" . substr($template, 13, 3) . "-1" . substr($template, 17, 3) . "-" . substr($template, 20, 12);
|
||
|
|
||
|
return $buildup;
|
||
|
}
|
||
|
?>
|