title: Java Brute Force Password Cracker
body: <p>I am making a brute force password cracker. I am able to use for loops to find which characters match the original password. But the output is not in the correct order. the output is in alphabetical order. How do i fix this?
  the output should be something like"</p>
  
  <pre><code>z
  ze
  zeb
  zebr
  zebra
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>        public static void main(String[] args) {
      String password = "zebra";
      char [] passArr = new char [password.length()];
      passArr = password.toCharArray();
  
      String brutePass = "";
      char[] alphabet = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p','q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
      boolean solved = false;
  
      while (solved != true) {
          for (int i = 0; i &lt; alphabet.length; i++) {
              for (int j = 0; j &lt; passArr.length; j++) {
                  if (alphabet[i] == passArr[j]) {
                      //brutePass +=passArr[j];
                      //System.out.println(brutePass);
  
                      StringBuilder forcedPass = new StringBuilder(brutePass);
                      forcedPass.insert(passArr[j], alphabet[i]);
                      System.out.println(forcedPass.toString());
                      solved = true;
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>}</p>