2017-03-02 59 views
0

當我運行該程序,沒有輸出,只是運行一段時間什麼也沒做,我試過把「!!!!!!」這是字符中的ASCII 33。這是我的代碼的第四或第五次迭代,我仍然無法實現它的工作。蠻力不工作,我找不到密鑰

這是我的計劃,

public class BruteForceTrue { 
    public static void main(String[] args) { 

     int z = 0;//Variable Declarations 
     int i = 0; 
     int u = 0; 
     int g = 0; 
     int d = 0; 
     int t = 0; 
     int w = 0; 
     char rechar1 = 0; 
     char rechar2 = 0; 
     char rechar3 = 0; 
     char rechar4 = 0; 
     char rechar5 = 0; 
     char rechar6 = 0; 
     String passT; 
     String passF = " " ; 
     StringBuilder sb = new StringBuilder(); 

     Scanner scanvar = new Scanner(System.in); 
     System.out.println("Challenge me to crack your pasword:");//Password Input 
     passT= scanvar.next(); 
     for(i=32;i<=127;i++){//For loop 1 
      rechar1 = ((char)i); 
      sb.setLength(0);//setting the list to blank 
      sb.append(rechar1);// setting the first character in the password 
      for (i=32;t<=127;t++){//For loop 2 
       rechar2 = ((char)t); 
       sb.append(rechar2); 
       for(d=32;d<=127;d++){//For loop 3 
        rechar3 = ((char)d); 
        sb.append(rechar3); 
        for(g=32;g<=127;g++){//For loop 4 
         rechar4 = ((char)g); 
         sb.append(rechar4); 
         for(w=32;w<=127;w++){//For loop 
          rechar5 = ((char)w); 
          sb.append(rechar5); 
          for(u=32;u<=127;u++){//For loop 
           rechar6 = ((char)u); 
           sb.append(rechar6); 
           String ans = sb.toString();//turning the list into a string 
           if (ans.equals(passT)) {//asking if the guess is the same as the passcode 
           System.out.println("the password is" + ans); 
            break; 

           } 
          } 
         } 
        } 
       } 
      } 
     } 
    } 
} 
+0

也許你的代碼太慢了。添加一些更多的輸出到你的代碼來獲得想法。 – Okas

回答

3

您的循環

for (i=32;t<=127;t++){//For loop 2 

第二要有t=32,不i=32