= 1'); } // charlist is empty or not provided if (empty($charlist)) { $numBytes = ceil($length * 0.75); $bytes = static::getBytes($numBytes); return mb_substr(rtrim(base64_encode($bytes), '='), 0, $length, '8bit'); } $listLen = mb_strlen($charlist, '8bit'); // phpcs:ignore SlevomatCodingStandard.Operators.DisallowEqualOperators.DisallowedEqualOperator if ($listLen == 1) { return str_repeat($charlist, $length); } $result = ''; for ($i = 0; $i < $length; $i++) { $pos = static::getInteger(0, $listLen - 1); $result .= $charlist[$pos]; } return $result; } }