Skip to content

Instantly share code, notes, and snippets.

@jianingy
Created September 3, 2017 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jianingy/032a60c79cef0b31ecae3fcd4e8a5cf0 to your computer and use it in GitHub Desktop.
Save jianingy/032a60c79cef0b31ecae3fcd4e8a5cf0 to your computer and use it in GitHub Desktop.
simple 96 bits uuid
<?php
function uuid32() {
return sprintf("%08X", rand(0, pow(2, 32)));
}
function uuid96() {
$uuid = uuid32() . uuid32() . uuid32();
$serial = "";
foreach (str_split($uuid, 2) as $b) {
$serial .= chr(hexdec($b));
}
return $serial;
}
print base64_encode(uuid96()) . "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment