public static function random(
        $length         = 8,
        $allowedChars   = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXY346789'
    ) {
        $return     = '';
        $hashLength = strlen($allowedChars) - 1;

        for (;$length > 0; --$length) {
            $return .= $allowedChars{rand(0, $hashLength)};
        }

        return str_shuffle($return);
    }
public static function random(
        $length         = 8,
        $allowedChars   = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXY346789'
    ) {
        $return     = '';
        $hashLength = strlen($allowedChars) - 1;

        for (;$length > 0; --$length) {
            $return .= $allowedChars{rand(0, $hashLength)};
        }

        return str_shuffle($return);
    }
Returns a random string with the given length and given string of
allowed characters.

@param int $length The length of the random string
@param string $allowedChars Allowed chars
@return string