Generates a unique id

@return String: a random string with timestamp
335413
public static String getUUID() {
        long timeInSeconds = new Date().getTime();
        String randomChars = TestCase.getRandomString(10);
        return timeInSeconds + "_" + randomChars;
    }
1013582
def uniqueID(size=6, chars=string.ascii_uppercase + string.digits):
    """"""
    return ''.join(random.choice(chars) for x in xrange(size))
148456
public static function generate()
    {
        if (version_compare(PHP_VERSION, '7.0.0', '<')) {
            return 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)
            );
        } else {
            $uuid = bin2hex(random_bytes(18));
            $uuid[8] = $uuid[13] = $uuid[18] = $uuid[23] = '-';
            $uuid[14] = '4';

            return $uuid;
        }
    }
854818
private function generateUniqueToken() {
		$s = strtoupper(md5(uniqid(rand(),true))); 
    	return substr($s,0,8) . '-' . 
	        substr($s,8,4) . '-' . 
	        substr($s,12,4). '-' . 
	        substr($s,16,4). '-' . 
	        substr($s,20); 
	}
1365021
public function getId()
    {
        if ( empty( $this->id ) )
        {
            if ( $this->getColumnsUseTranslation() )
            {
                $id = trim( $this->getColumnTranslatePrefix() . '.' .
                            $this->getColumnTranslatePostfix(), '.' );

                if ( ! empty( $id ) )
                {
                    return str_replace( '.', '_', $id );
                }
            }

            $this->id = String::generateRandom();
        }

        return $this->id;
    }
1143166
public static function createGUID() {
        if (function_exists('com_create_guid')) {
            return substr(com_create_guid(),1,36);
        }
        else {
            mt_srand((double) microtime() * 10000);
            $charid = strtoupper(md5(uniqid(rand(), true)));
            $hyphen = chr(45);
            $uuid = substr($charid, 0, 8) . $hyphen .
                    substr($charid, 8, 4) . $hyphen .
                    substr($charid, 12, 4) . $hyphen .
                    substr($charid, 16, 4) . $hyphen .
                    substr($charid, 20, 12);

            return $uuid;
        }
    }
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);
    }
936197
function getUuid() {
    return $this->time_low . '-' . $this->time_mid . '-' . $this->time_hi_version . '-' . $this->clock_seq_hi_variant . $this->clock_seq_low . '-' . $this->node;
  }
803561
public function generateID()
    {
        $id = $this->getID();
        $fmt_string = "%08s";
        if (is_array($id))
            $id = implode("-", $id);

        if (empty($id))
            throw new Exception("Cannot generate an ID for an empty object");

        $id = substr(sha1($id), 0, 10);
        $acl_class = $this->getACLClass();

        return $acl_class . "#" . $id;
    }
504339
public function generateUuid() {
        if (is_readable(self::UUID_SOURCE)) {
            $uuid = trim(file_get_contents(self::UUID_SOURCE));
        } elseif (function_exists('mt_rand')) {
            /**
             * Taken from stackoverflow answer, possibly not the fastest or
             * strictly standards compliant
             * @link http://stackoverflow.com/a/2040279
             */
            $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)
            );
        } else {
            // chosen by dice roll, guaranteed to be random
            $uuid = '4';
        }
        return $uuid;
    }
1003203
public function generate(): string
    {
        $uniqueId = uniqid((string) rand(), true);

        return (string) md5($uniqueId);
    }
1110806
protected function generate_session_id() {
		$length = 40;

		require_once ABSPATH . 'wp-includes/class-phpass.php';
		$bytes = ( new \PasswordHash( 8, false ) )->get_random_bytes( $length * 2 );

		return substr( str_replace( [ '/', '+', '=' ], '', base64_encode( $bytes ) ), 0, $length );
	}
475467
public static function generateSession()
    {
        $sessionID = TextHelper::random(20, 'qwertyuiopasdfghjklzxcvbnm1234567890');
        Base::getLog()->debug(__METHOD__ . ' generate session id', [
            'id' => $sessionID,
        ]);
        return $sessionID;
    }
1246540
public function generateId($intLength = 8)
    {
        $strChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        $strReturn = '';

        srand((double) microtime() * 1000000);

        for ($i = 1; $i <= $intLength; $i ++) {
            $intNum = rand() % (strlen($strChars) - 1);
            $strTmp = substr($strChars, $intNum, 1);
            $strReturn .= $strTmp;
        }

        return $strReturn;
    }
574770
public static function NewGuid()
    {
        if (function_exists('com_create_guid')) {
            return trim(com_create_guid(), "{}");
        } else {
            $charid = strtoupper(bin2hex(openssl_random_pseudo_bytes(16)));
            $hyphen = chr(45);
            $uuid = substr($charid, 0, 8) . $hyphen . substr($charid, 8, 4) . $hyphen . substr($charid, 12, 4) . $hyphen . substr($charid, 16, 4) . $hyphen . substr($charid, 20, 12);
            return $uuid;
        }
    }
690951
protected function generate()
    {
        $hash = bin2hex(random_bytes(16));

        $timeHi = hexdec(substr($hash, 12, 4)) & 0x0fff;
        $timeHi &= ~(0xf000);
        $timeHi |= 4 << 12;

        $clockSeqHi = hexdec(substr($hash, 16, 2)) & 0x3f;
        $clockSeqHi &= ~(0xc0);
        $clockSeqHi |= 0x80;

        $params = [substr($hash, 0, 8), substr($hash, 8, 4), sprintf('%04x', $timeHi), sprintf('%02x', $clockSeqHi), substr($hash, 18, 2), substr($hash, 20, 12)];

        return vsprintf('%08s-%04s-%04s-%02s%02s-%012s', $params);
    }
1021001
public function sampleId()
    {
        if (!$this->sampleId) {
            $this->sampleId = $this->inputId() ?: $this->generateSampleId();
        }

        return $this->sampleId;
    }