Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. public class Brute {
  2.  
  3.     long  numCombinazioni=0;
  4.    
  5.    
  6.     public String start(char charSet[], String password,char tryPassword[],int coulums[]) {
  7.  
  8.    
  9.     //Inizio Ricerca esaustiva
  10.     while(true) {
  11.          
  12.    
  13.     for(int c=0;c<=charSet.length-1;c++) {
  14.            
  15.         numCombinazioni++;
  16.                        
  17.        tryPassword[tryPassword.length-1]=charSet[c];
  18.            
  19.         String p=new String(tryPassword);
  20.              
  21.        System.out.println(p);
  22.      
  23.                  if(p.equals(password)) {
  24.              System.out.println("Password : "+p+" numero combinazioni provate "+  numCombinazioni);
  25.        
  26.                return p;
  27.    
  28.                  }
  29.              
  30. }    
  31.  
  32.    
  33.     int i=password.length();
  34.    
  35.     for(int c=tryPassword.length-1;c>=0;c--){
  36.        
  37.         if(tryPassword[c]==charSet[charSet.length-1]) {
  38.        
  39.         i=c-1; tryPassword[c]=charSet[0];    
  40.            coulums[i]++;   coulums[i+1]=0;
  41.                    
  42.            tryPassword[c-1]=charSet[coulums[i]];
  43.    
  44.         }
  45.       }
  46.  
  47.     }
  48.    
  49.     }
  50.    
  51.    
  52.    
  53.    
  54.    
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement