src/sb/Password/Random.php
protected function generate()
    {

        $this->password = '';

        $chars = range('a', 'z');

        $symbols = Array('*', '&', '^', '%', '$', '#', '@', '!');

        $chars = array_merge($chars, $symbols);

        //get rid of l and o as they can be confused with 1 and 0
        unset($chars[11]);
        unset($chars[14]);

        $chars = array_values($chars);

        $chars_length = count($chars);

        foreach (range(1, $this->length) as $char) {

            $char = '';

            $integer = rand(2, 9).'';
            $new_char = $chars[rand(0, $chars_length - 1)];
            if (strstr($this->password, $new_char)) {
                $char = $new_char;
            } elseif (strstr($this->password, $integer)) {
                $char = $integer;
            } else {
                $char = rand(0, 1) ? $new_char : $integer;
            }

            $this->password .= $char;
        }

        $this->password = substr_replace($this->password, array_rand($symbols), rand(0, strlen($this->password)), 1);
    }
protected function generate()
    {

        $this->password = '';

        $chars = range('a', 'z');

        $symbols = Array('*', '&', '^', '%', '$', '#', '@', '!');

        $chars = array_merge($chars, $symbols);

        //get rid of l and o as they can be confused with 1 and 0
        unset($chars[11]);
        unset($chars[14]);

        $chars = array_values($chars);

        $chars_length = count($chars);

        foreach (range(1, $this->length) as $char) {

            $char = '';

            $integer = rand(2, 9).'';
            $new_char = $chars[rand(0, $chars_length - 1)];
            if (strstr($this->password, $new_char)) {
                $char = $new_char;
            } elseif (strstr($this->password, $integer)) {
                $char = $integer;
            } else {
                $char = rand(0, 1) ? $new_char : $integer;
            }

            $this->password .= $char;
        }

        $this->password = substr_replace($this->password, array_rand($symbols), rand(0, strlen($this->password)), 1);
    }
protected function generate ( ) { $ this -> password = '' ; $ chars = range ( 'a' , 'z' ) ; $ symbols = Array ( '*' , '&' , '^' , '%' , '$' , '#' , '@' , '!' ) ; $ chars = array_merge ( $ chars , $ symbols ) ; //get rid of l and o as they can be confused with 1 and 0 unset ( $ chars [ 11 ] ) ; unset ( $ chars [ 14 ] ) ; $ chars = array_values ( $ chars ) ; $ chars_length = count ( $ chars ) ; foreach ( range ( 1 , $ this -> length ) as $ char ) { $ char = '' ; $ integer = rand ( 2 , 9 ) . '' ; $ new_char = $ chars [ rand ( 0 , $ chars_length - 1 ) ] ; if ( strstr ( $ this -> password , $ new_char ) ) { $ char = $ new_char ; } elseif ( strstr ( $ this -> password , $ integer ) ) { $ char = $ integer ; } else { $ char = rand ( 0 , 1 ) ? $ new_char : $ integer ; } $ this -> password .= $ char ; } $ this -> password = substr_replace ( $ this -> password , array_rand ( $ symbols ) , rand ( 0 , strlen ( $ this -> password ) ) , 1 ) ; }
Generates the password randomly
Generates the password randomly