SOLVED custom app UUID

Status
Not open for further replies.

benw

Member
Jan 21, 2019
30
2
8
38
anyone tell me how uuid works?

is it something i have to generate via postgres or do i use a random generated of my own.
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,417
376
83
For generating type 4 UUIDs I use this simple bit of code, it's not my work but I don't know where it came from:
Code:
#!/usr/bin/php
<?php

echo sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
    mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
    mt_rand( 0, 0xffff ),
    mt_rand( 0, 0x0fff ) | 0x4000,
    mt_rand( 0, 0x3fff ) | 0x8000,
    mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ))."\n";

?>

Adrian.
 
Status
Not open for further replies.