Generate a random UUID v4 in hex format.

@codeCoverageIgnore

@return string
550216
private function generate(): void
    {
        $this->hexUUID = \sprintf(
            '%s-%s-%s-%s-%s',
            // 8 hex characters
            \bin2hex(\random_bytes(4)),
            // 4 hex characters
            \bin2hex(\random_bytes(2)),
            // "4" for the UUID version + 3 hex characters
            // 0x4000 is 16384 in int
            // 0x4fff is 20479 in int
            \dechex(\random_int(16384, 20479)),
            // (8, 9, a, or b) for the UUID variant 1 plus 3 hex characters
            //  0x8000 is 32768 in int
            //  0xbfff is 49151 in int
            \dechex(\random_int(32768, 49151)),
            // 12 hex characters
            \bin2hex(\random_bytes(6))
        );
    }
764655
public static function createUUID()
    {
        return self::create(
                sprintf(
                    '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
                    // 32 bits for "time_low"
                    mt_rand(0, 0xffff), mt_rand(0, 0xffff),
                    // 16 bits for "time_mid"
                                                mt_rand(0, 0xffff),
                    // 16 bits for "time_hi_and_version",
                    // four most significant bits holds version number 4
                                                        mt_rand(0, 0x0fff) | 0x4000,
                    // 16 bits, 8 bits for "clk_seq_hi_res",
                    // 8 bits for "clk_seq_low",
                    // two most significant bits holds zero and one for variant DCE1.1
                                                                mt_rand(0, 0x3fff) | 0x8000,
                    // 48 bits for "node"
                                                                        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
                )
        );
    }
389767
public static function generateUid():string
    {
        static $uid = null;
        if ($uid === null) {
            $now = \DateTime::createFromFormat('U.u', microtime(true), static::timezone());
            $uid = md5($now->format("Y-m-d\TH:i:s.uO"));
        }
        return $uid;
    }
858884
public static function generateId()
    {
        $microtime         = microtime(true);
        $includeFloatMtime = str_replace(array('.', '.'), '', $microtime);
        $random            = mt_rand(1000, 8888);
        $uniqid            = ($includeFloatMtime + $random);
        return base_convert($uniqid, 10, 36);
    }
353380
public static function generate ()
		{
			$data = random_bytes(16);

			$data[ 6 ] = chr(ord($data[ 6 ]) & 0x0f | 0x40); // set version to 0100
			$data[ 8 ] = chr(ord($data[ 8 ]) & 0x3f | 0x80); // set bits 6-7 to 10

			return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
		}
921633
public static function uuid()
    {
        mt_srand((double)microtime() * 10000);
        $charId = md5(uniqid(rand(), true));
        $uuid = [
            substr($charId, 0, 8),
            substr($charId, 8, 4),
            substr($charId, 12, 4),
            substr($charId, 16, 4),
            substr($charId, 20, 12)
        ];

        return join('-', $uuid);
    }
1183105
public static function generate(): string
  {
    return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
        // 32 bits for "time_low"
        \mt_rand( 0, 0xffff ), \mt_rand( 0, 0xffff ),

        // 16 bits for "time_mid"
        \mt_rand( 0, 0xffff ),

        // 16 bits for "time_hi_and_version",
        // four most significant bits holds version number 4
        \mt_rand( 0, 0x0fff ) | 0x4000,

        // 16 bits, 8 bits for "clk_seq_hi_res",
        // 8 bits for "clk_seq_low",
        // two most significant bits holds zero and one for variant DCE1.1
        \mt_rand( 0, 0x3fff ) | 0x8000,

        // 48 bits for "node"
        \mt_rand( 0, 0xffff ), \mt_rand( 0, 0xffff ), \mt_rand( 0, 0xffff )
    );
  }
5050
private function genUID() {
        // HTTP_CLIENT_IP and HTTP_X_FORWARDE‌​D_FOR can be forged.
        // REMOTE_ADDR is the same for all clients connected to a proxy.
        $ip=@$_SERVER['HTTP_CLIENT_IP'].@$_SERVER['HTTP_X_FORWARDE‌​D_FOR'].@$_SERVER['REMOTE_ADDR'];
        // HTTP_USER_AGENT could be forge.
        $browser=@$_SERVER['HTTP_USER_AGENT'];
        return md5($ip.$browser);
    }
794904
function uuid() {
    var i, random;
    var uuid = '';

    for (i = 0; i < 32; i++) {
        random = Math.random() * 16 | 0;
        if (i === 8 || i === 12 || i === 16 || i === 20) {
            uuid += '-';
        }
        uuid += (i === 12 ? 4 : (i === 16 ? (random & 3 | 8) : random)).toString(16);
    }

    return uuid;
}
434032
public static function createUuid() {
		$data = \openssl_random_pseudo_bytes(16);

		// set the version to 0100
		$data[6] = \chr(\ord($data[6]) & 0x0f | 0x40);
		// set bits 6-7 to 10
		$data[8] = \chr(\ord($data[8]) & 0x3f | 0x80);

		return \vsprintf('%s%s-%s-%s-%s-%s%s%s', \str_split(\bin2hex($data), 4));
	}
1003203
public function generate(): string
    {
        $uniqueId = uniqid((string) rand(), true);

        return (string) md5($uniqueId);
    }
1177855
function uuid4() {
	  var d = now();
	  var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
	    var r = (d + Math.random() * 16) % 16 | 0;
	    d = Math.floor(d / 16);
	    return (c === 'x' ? r : (r & 0x7 | 0x8)).toString(16);
	  });
	  return uuid;
	}
1352938
public static function uuid4()
    {
        mt_srand();
        return sprintf(
            '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
            // 32 bits for "time_low"
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff),
            // 16 bits for "time_mid"
            mt_rand(0, 0xffff),
            // 16 bits for "time_hi_and_version",
            // four most significant bits holds version number 4
            mt_rand(0, 0x0fff) | 0x4000,
            // 16 bits, 8 bits for "clk_seq_hi_res",
            // 8 bits for "clk_seq_low",
            // two most significant bits holds zero and one for variant DCE1.1
            mt_rand(0, 0x3fff) | 0x8000,
            // 48 bits for "node"
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff)
        );
    }
280883
public static function uuid(): string
    {
        $chars = md5(uniqid(mt_rand(0, mt_getrandmax()), true));
        $uuid = substr($chars, 0, 8) . '-';
        $uuid .= substr($chars, 8, 4) . '-';
        $uuid .= substr($chars, 12, 4) . '-';
        $uuid .= substr($chars, 16, 4) . '-';
        $uuid .= substr($chars, 20, 12);
        return $uuid;
    }
93264
public static function uuid($version = self::UUID_V4){

        switch($version){
            case self::UUID_V4:
                $data = openssl_random_pseudo_bytes(16);

                $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0010
                $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10

                return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));

            default:
                throw new Exception("Invalid or unknown uuid version specified");
        }
    }
659713
public function generate()
    {
        $chars = $this->validChars();
        $numChars = strlen($chars) - 1;
        $length = $this->getLength();
        $code = array();
        for ($i = 0; $i < $length; ++$i) {
            $code[] = $chars[random_int(0, $numChars)];
        }

        return implode('', $code);
    }
657917
function uuid() {
  return crypto.randomBytes(4).toString('hex') + '-' +
    crypto.randomBytes(2).toString('hex') + '-' +
    crypto.randomBytes(2).toString('hex').replace(/^./, '1') + '-' +
    crypto.randomBytes(2).toString('hex') + '-' +
    crypto.randomBytes(6).toString('hex')
}