ManaPHP\Security\Random::getBase PHP Метод

getBase() публичный Метод

public getBase ( integer $length, integer $base = 62 ) : string
$length integer
$base integer
Результат string
    public function getBase($length, $base = 62)
    {
        $str = '';
        $bytes = $this->getByte($length);
        /** @noinspection ForeachInvariantsInspection */
        for ($i = 0; $i < $length; $i++) {
            $r = ord($bytes[$i]) % $base;
            if ($r < 10) {
                $str .= chr(ord('0') + $r);
            } elseif ($r < 36) {
                $str .= chr(ord('a') + $r - 10);
            } else {
                $str .= chr(ord('A') + $r - 36);
            }
        }
        return $str;
    }