Returns a V4 UUID.

@return string
488841
public static function v4(): string
	{
		$random = random_bytes(16);

		$random[6] = chr(ord($random[6]) & 0x0f | 0x40);

		$random[8] = chr(ord($random[8]) & 0x3f | 0x80);

		return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($random), 4));
	}
105876
static public function uuid() {
        $charid = md5(uniqid(mt_rand(), true));
        $hyphen = chr(45);// "-"
        $uuid = chr(123)// "{"
               .substr($charid, 0, 8).$hyphen
               .substr($charid, 8, 4).$hyphen
               .substr($charid,12, 4).$hyphen
               .substr($charid,16, 4).$hyphen
               .substr($charid,20,12)
               .chr(125);// "}"
        return $uuid;
    }
337024
public static function uuid()
    {
        $node = getenv('SERVER_ADDR');
        if (strpos($node, ':') !== false) {
            if (substr_count($node, '::')) {
                $node = str_replace(
                    '::',
                    str_repeat(':0000', 8 - substr_count($node, ':')) . ':',
                    $node
                );
            }
            $node = explode(':', $node);
            $ipSix = '';
            foreach ($node as $id) {
                $ipSix .= str_pad(base_convert($id, 16, 2), 16, 0, STR_PAD_LEFT);
            }
            $node = base_convert($ipSix, 2, 10);
            if (strlen($node) < 38) {
                $node = null;
            } else {
                $node = crc32($node);
            }
        } elseif (empty($node)) {
            $host = getenv('HOSTNAME');
            if (empty($host)) {
                $host = getenv('HOST');
            }
            if (!empty($host)) {
                $ip = gethostbyname($host);
                if ($ip === $host) {
                    $node = crc32($host);
                } else {
                    $node = ip2long($ip);
                }
            }
        } elseif ($node !== '127.0.0.1') {
            $node = ip2long($node);
        } else {
            $node = null;
        }
        if (empty($node)) {
            $node = crc32(Strata::app()->getConfig('security.salt'));
        }
        if (function_exists('hphp_get_thread_id')) {
            $pid = hphp_get_thread_id();
        } elseif (function_exists('zend_thread_id')) {
            $pid = zend_thread_id();
        } else {
            $pid = getmypid();
        }
        if (!$pid || $pid > 65535) {
            $pid = mt_rand(0, 0xfff) | 0x4000;
        }
        list($timeMid, $timeLow) = explode(' ', microtime());
        return sprintf(
            "%08x-%04x-%04x-%02x%02x-%04x%08x",
            (int)$timeLow,
            (int)substr($timeMid, 2) & 0xffff,
            mt_rand(0, 0xfff) | 0x4000,
            mt_rand(0, 0x3f) | 0x80,
            mt_rand(0, 0xff),
            $pid,
            $node
        );
    }
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;
    }
89727
public static function version()
    {
        return function ($version, $service, $region) {
            switch ($version) {
                case 's3v4':
                case 'v4':
                    return !empty(self::$s3v4SignedServices[$service])
                        ? new S3SignatureV4($service, $region)
                        : new SignatureV4($service, $region);
                case 'v4-unsigned-body':
                    return new SignatureV4($service, $region, ['unsigned-body' => 'true']);
                case 'anonymous':
                    return new AnonymousSignature();
                default:
                    return null;
            }
        };
    }
738146
private function getAppKey(): string
    {
        $appUUID = $this
            ->getRepositoryReference()
            ->getAppUUID();

        return $appUUID instanceof AppUUID
            ? $appUUID->getId()
            : '';
    }
1238430
public function getIVKey()
    {
        if (!$this->iv) {
            $ivSize = $this->getIVSize();

            $this->iv = mcrypt_create_iv($ivSize, MCRYPT_RAND);
        }

        return $this->iv;
    }
1072736
public function generateGUID5()
    {
        $hash = $this->generateUUID();

        $uuid = sprintf('%08s-%04s-%04x-%04x-%12s', // 32 bits for "time_low"
            substr($hash, 0, 8), // 16 bits for "time_mid"
            substr($hash, 8, 4), // 16 bits for "time_hi_and_version",
            // four most significant bits holds version number 5
            (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000, // 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
            (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000, // 48 bits for "node"
            substr($hash, 20, 12));

        return $uuid;
    }
1299070
public static function getUUID(): string {
        $data = random_bytes(16);
        $data[6] = chr(ord($data[6]) & 0x0f | 0x40);
        $data[8] = chr(ord($data[8]) & 0x3f | 0x80);
        return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
    }
655003
protected function generateUUID()
        {
        $uuid = null;
        if ($this->useUUIDs) {
            $sql    = 'SELECT UUID() as id';
            $result = $this->database->fetchAssoc($sql);
            $uuid   = $result['id'];
        }
        return $uuid;
    }
709908
private function genUUIDPath() {
		$uid = $this->genUUID();
		$result = '/';

		$segments = 8;
		if($segments > strlen($uid) / 2) {
			$segments = strlen($uid) / 2;
		}
		for($i = 0; $i < $segments; $i ++) {
			$result .= substr($uid, $i * 2, 2).'/';
		}

		return $result;
	}
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");
        }
    }
534529
public String getUuid() {
    if (StringUtil.isEmpty(this.uuid)) {
      this.uuid = UUID.randomUUID().toString().toLowerCase();
    }
    return this.uuid;
  }
824308
public SIBUuid8 getUuid() {
		if (_uuid == null) {
			String s = "B0CEFAD4D3454A2E";
			_uuid = new SIBUuid8(s);
		}
		return _uuid;
	}
753039
public function generateUuid()
    {
        $serialized = serialize($this->envInformations);
        $this->uuid = dechex($this->getDate()->format('Ymd')) . substr(sha1(implode([
            microtime(),
            $serialized,
            $this->configPath,
        ])), 0, -7);
    }
109945
public static function cuid()
    {
        $prefix = 'c';
        $timestamp = Cuid::timestamp();
        $count = Cuid::count();
        $fingerprint = Cuid::fingerprint();
        $random = Cuid::random() . Cuid::random();

        return $prefix .
            $timestamp .
            $count .
            $fingerprint .
            $random;
    }
612543
protected static function mintRand(): string
    {
        $uuid = static::randomBytes(16);
        // set variant
        $uuid[8] = \chr(\ord($uuid[8]) & static::CLEAR_VAR | static::VAR_RFC);
        // set version
        $uuid[6] = \chr(\ord($uuid[6]) & static::CLEAR_VER | static::VERSION_4);

        return $uuid;
    }