IdGenerator from pollun/utils replacement:
Generate id.
Generates an arbitrary length string of cryptographic random
@param int $nums = 8;
@return string
@throws \Exception
551223
public static function IdGenerate($nums = 8)
    {
        /**
         * @var string
         */
        $idCharSet = "QWERTYUIOPASDFGHJKLZXCVBNM0123456789";

        $id = [];
        $idCharSetArray = str_split($idCharSet);
        $charArrayCount = count($idCharSetArray) - 1;

        for ($i = 0; $i < $nums; $i++) {
            $id[$i] = $idCharSetArray[random_int(0, $charArrayCount)];
        }

        $id = implode("", $id);

        return $id;
    }
1003203
public function generate(): string
    {
        $uniqueId = uniqid((string) rand(), true);

        return (string) md5($uniqueId);
    }
1039358
protected function generateId()
    {
        static $choices = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $id = '';
        while (strlen($id) < 9) {
            $id .= $choices[ mt_rand(0, strlen($choices) - 1) ];
        }
        return $id;
    }
353360
protected function generate($length = 40)
    {
        try {
            return bin2hex(random_bytes($length / 2));
        } catch (\TypeError $e) {
            // This is okay, so long as `Error` is caught before `Exception`.
            throw new \common_Exception("An unexpected error has occurred while trying to generate a security token", 0, $e);
        } catch (\Error $e) {
            // This is required, if you do not need to do anything just rethrow.
            throw new \common_Exception("An unexpected error has occurred while trying to generate a security token", 0, $e);
        } catch (\Exception $e) {
            throw new \common_Exception("Could not generate a security token. Is our OS secure?", 0, $e);
        }
    }
485583
public function generate($length=10, $availables=self::CHAR_ALPHADIGIT, array $tokens=array(self::CHAR_ALPHA, self::CHAR_DIGIT)) {
		$tokens	= array_pad($tokens, $length, $availables);
		shuffle($tokens);
		$password	= '';
		foreach( $tokens as $token ) {
			$tokenChars = '';
			foreach( $this->primarySets as $flag => $chars ) {
				if( bintest($token, $flag) ) {
					$tokenChars .= $chars;
				}
			}
			$password .= $tokenChars[mt_rand(0, strlen($tokenChars)-1)];
		}
		return $password;
	}
653759
private function generateId()
    {
        $randomNumber = mt_rand(0, mt_getrandmax());
        $ipAddressFragment = md5(substr($this->ipAddress, 0, 5));
        $timestamp = md5(microtime(true) . $this->now);

        return hash('sha256', $randomNumber . $ipAddressFragment . $this->salt . $timestamp);
    }
724139
private function getRand($num = 6){
		$string = '';
		$source = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_';
		$length = strlen($source);
		while(strlen($string) < $num){
			$string .= substr($source,rand(0,1000)%$length,1);
		}
		return $string;
	}
731228
public function id($ids){
        $ids = (array)$ids;
        if (count($ids) !== count($this->config['pkeys']))
            throw new Exception('Unmatched id count ' . count($ids)
                                . ':' . count($this->config['pkeys']));
        $pkeys = $this->config['pkeys'];
        foreach ($pkeys as $i => $pkey)
            $this->where->eq(array($this->voName . '.' . Util::toVoName($pkey) =>$ids[$i]));

        return $this;
    }
835477
def generate_random_id(size=6, chars=string.ascii_uppercase + string.digits):
    """"""
    return "".join(random.choice(chars) for x in range(size))
45594
final function _generateID()
    {
        $uniqStr = function($length) {
            $char = "abcdefghijklmnopqrstuvwxyz0123456789";
            $char = str_shuffle($char);
            for($i = 0, $rand = '', $l = strlen($char) - 1; $i < $length; $i ++) {
                $rand .= $char{mt_rand(0, $l)};
            }

            return $rand;
        };

        if ($this->ID == null) {
            $class     = get_called_class();
            $module    = $this->deriveModuleNamespace($class);
            $widget    = $this->deriveWidgetName($class);

            $this->ID  = (($module != '') ? $this->inflectName($module).'_' : '')
                .$this->inflectName($widget).'_'.$uniqStr(5);
        }

        return $this->ID;
    }
1174924
public function generatePermid()
    {
        if($this->permid)
        {
            return $this;
        }

        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        //random string always begins with a letter
        $randomString = $characters[rand(10, strlen($characters) - 1)];
        for ($i = 1; $i < 24; $i++) {
            $randomString .= $characters[rand(0, strlen($characters) - 1)];
        }
        $this->permid = $randomString;

        return $this;
    }
925396
public function generateId(): string
    {
        if ($this->saveHandler != null && method_exists($this->saveHandler, 'generateId')) {
            return $this->saveHandler->generateId($id);
        }

        $id = session_create_id();

        // hash by length
        if ($this->options['hash']) {
            switch ($this->options['hashLength']) {
                case 32: $id = hash('md5', $id); break;
                case 40: $id = hash('sha1', $id); break;
                case 64: $id = hash('sha256', $id); break;
                case 128: $id = hash('sha512', $id); break;
                default:
                    throw new SessionException("No valid 'hashLength' option given, only ".
                        "'32,40,64,128' are accepted");
            }
            $id = strtoupper($id);
        }

        return $id;
    }
1127961
public function nextId()
    {
        $timestamp = floor(microtime(true) * 1000) - $this->epochTimeStamp;
        if($timestamp > $this->maxTimeStamp) {
            throw new Exception('Snowflake: TimeStamp overflow. Unable to generate any more IDs');
        }
        
        $machine = $this->machineId;
        if($machine < 0 || $machine > 1023) {
            throw new Exception('Snowflake: Machine ID out of range');
        }
        $sequence = mt_rand(0, 4095);
        if(PHP_INT_SIZE == 4) {
            return $this->makeId32($timestamp, $machine, $sequence);
        } else {
            return $this->makeId64($timestamp, $machine, $sequence);
        }
    }
662359
function samlCreateId() 
   {
      $rndChars = 'abcdefghijklmnop';
      $rndId = '';
      for ($i = 0; $i < 40; $i++ ) {
         $rndId .= $rndChars[rand(0,strlen($rndChars)-1)];
      }
      return $rndId;
   }
1304763
public static function generateId()
    {
        static $inc = 0;

        $ts = pack('N', time());
        $m = substr(md5(gethostname()), 0, 3);
        $pid = pack('n', 1);
        $trail = substr(pack('N', $inc++), 1, 3);

        $bin = sprintf('%s%s%s%s', $ts, $m, $pid, $trail);
        $id = '';
        for ($i = 0; $i < 12; $i++) {
            $id .= sprintf('%02X', ord($bin[$i]));
        }

        return strtolower($id);
    }
160241
private static function generatePoolClientId()
    {
        $now = ceil(microtime(true) * 10000);
        if (class_exists('Reaction', false)) {
            $rand = \Reaction::$app->security->generateRandomString(8);
        } else {
            $rand = static::randomStr();
        }
        return static::getClientIdPrefix() . $now . $rand;
    }
475467
public static function generateSession()
    {
        $sessionID = TextHelper::random(20, 'qwertyuiopasdfghjklzxcvbnm1234567890');
        Base::getLog()->debug(__METHOD__ . ' generate session id', [
            'id' => $sessionID,
        ]);
        return $sessionID;
    }