Generate a random UUID for folder name (version 4).

@see http://www.ietf.org/rfc/rfc4122.txt

@return string RFC 4122 UUID

@copyright Matt Farina MIT License https://github.com/lootils/uuid/blob/master/LICENSE
351550
public function getUniqueFolderName()
    {
        return sprintf(
            '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
            mt_rand(0, 65535),
            mt_rand(0, 65535),
            mt_rand(0, 65535),
            mt_rand(0, 4095) | 0x4000,
            mt_rand(0, 0x3fff) | 0x8000,
            mt_rand(0, 65535),
            mt_rand(0, 65535),
            mt_rand(0, 65535)
        );
    }
1044421
protected function calculateUuid()
    {
        try {
            // Generate a version 4 (random) UUID object
            $uuid4 = Uuid::uuid4();
            $uuid  = $uuid4->toString();
        } catch (UnsatisfiedDependencyException $exception) {
            throw new Doozr_Registry_Exception($exception->getMessage(), $exception->getCode(), $exception);
        }

        return $uuid;
    }
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;
    }
79475
public function getUuid() : ?string 
    {
        if ( ! $this->hasUuid()) {
            $this->setUuid($this->getDefaultUuid());
        }
        return $this->uuid;
    }
1003203
public function generate(): string
    {
        $uniqueId = uniqid((string) rand(), true);

        return (string) md5($uniqueId);
    }
496182
final public static function generateUidie():string
    {
        // i for iumio
        $str = "i";
        // Create a string with Alphabetic letter
        $str .= chr(rand(65, 90));
        // Insert the timestamp
        $str .= time();
        // Create an other unique identifier with lenght 5
        $uniqid = substr(uniqid("X"), 5);
        // concat all
        $str .= substr($uniqid, 5);

        return ($str);
    }
671723
public function getUid()
    {
        $session_user_id = $this->user->getId();

        if (!empty($session_user_id)) {
            return (string) $session_user_id;
        }

        $cookie_name = $this->getCookieUserName();
        $cookie_user_id = $this->request->cookie($cookie_name, '', 'string');

        if (!empty($cookie_user_id)) {
            return $cookie_user_id;
        }

        $generated_user_id = '_' . gplcart_string_random(6);
        $this->request->setCookie($cookie_name, $generated_user_id, $this->getCookieLifespan());
        return $generated_user_id;
    }
1237758
private function randomFileName()
    {
        $fileName = '';

        // Generate the datetime format file name
        if ($this->randomNameType == 1)
        {
            date_default_timezone_set($this->timezone);

            $date     = date($this->randomLength);
            echo $dir      = $this->savePath . $date;

            if ( !file_exists($dir) ) {
                mkdir($dir, $this->mode, true);
            }

            $fileName = $date . '/' . time();
        }
        elseif ($this->randomNameType == 2)    // Generate random character file name
        {
            $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
            $max   = strlen($chars) - 1;
            mt_srand( (double) microtime() * 1000000);

            for ($i = 0; $i < $this->randomLength; $i++)
            {
                $fileName .= $chars[mt_rand(0, $max)];
            }
        }
        else
        {
        }

        $this->fileExt = $this->getFileExt($this->files["name"]);

        $fileName = $fileName . '.' . $this->fileExt;

        return $fileName;
    }
5187
public static function uniqid()
    {
        static $n = 0;
        return str_shuffle(
            md5(
                str_shuffle(
                    microtime(true) . chr(mt_rand(0, 0xFF))
                    . Daemon::$process->getPid() . chr(mt_rand(0, 0xFF))
                    . (++$n) . mt_rand(0, mt_getrandmax())
                )
            )
        );
    }
139081
private function generateUuid()
    {
        $args = $this->version;
        $fn = 'uuid'.array_shift($args);

        return call_user_func_array('Ramsey\Uuid\Uuid::'.$fn, $args);
    }
655003
protected function generateUUID()
        {
        $uuid = null;
        if ($this->useUUIDs) {
            $sql    = 'SELECT UUID() as id';
            $result = $this->database->fetchAssoc($sql);
            $uuid   = $result['id'];
        }
        return $uuid;
    }
402389
private function uuid4()
    {
        $uuid = 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)
        );

        return str_replace('-', '', $uuid);
    }
258972
public function generatePadID(): string
    {
        $chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
        $length = 16;
        $padID = "";

        for ($i = 0; $i < $length; $i++) {
            $padID .= $chars[rand() % strlen($chars)];
        }

        return $padID;
    }
708060
public static function create()
    {
        // use COM helper if available
        if (function_exists('com_create_guid')) {
            return com_create_guid();
        }

        // generate UUID
        mt_srand((double) microtime() * 10000); // optional for php 4.2.0 and up.
        $charid = strtoupper(md5(uniqid(rand(), true)));
        $uuid = join('-', array(
            substr($charid, 0, 8),
            substr($charid, 8, 4),
            substr($charid, 12, 4),
            substr($charid, 16, 4),
            substr($charid, 20, 12),
        ));

        return $uuid;
    }
1247871
protected function getClientUid() {
		$clientUid = '';
		if($this->publicKeyByIp) {
			if(isset($_SERVER['REMOTE_ADDR'])) {
				$clientUid .= $_SERVER['REMOTE_ADDR'];
			}
			if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
				$clientUid .= $_SERVER['HTTP_X_FORWARDED_FOR'];
			}
		}
		return $clientUid;
	}
1016423
protected function _generateUUID()
    {
        $data = null;
        switch (true) {
            case $this->_isCallable('random_bytes'):
                $data = $this->_randomBytes(16);
                break;
            case $this->_isCallable('openssl_random_pseudo_bytes'):
                $data = $this->_opensslRandomPseudoBytes(16);
                break;
            case $this->_isCallable('mt_rand'):
                $data = $this->_generateBytesWithMtRand(16);
                break;
            default:
                return 'unavailable';
        }

        return $this->_generateUUIDFromData($data);
    }
245973
public function genUid() {
    $rand = $this['crypt/rand'];

    $hex = bin2hex($rand->Bytes(32));
    $str = substr($hex,0,16) . '-' . substr($hex,16,8) . '-' . substr($hex,24,8) . '-' . substr($hex,32,8) . '-' . substr($hex,40,24);
    return $str;
  }