daktarism

Password Cracker with length information

Mar 16th, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     string password;
  9.     string generatedPass;
  10.  
  11.     cout << "gimme tha password dawg" << endl;
  12.     cin >> password;
  13.  
  14.     char digitArray[]={'a'-1,'a','a','a','a','a','a','a','a','a'};
  15.  
  16.     while( password.compare(generatedPass) != 0 ){
  17.  
  18.         digitArray[0]++;
  19.         for(int x=0;x<password.length();x++){
  20.            if (digitArray[x] == 'z'+1)
  21.                 {
  22.                     digitArray[x] = 'a';
  23.                     digitArray[x + 1]++;
  24.                 }
  25.         }
  26.  
  27.         // creating the string with those digits
  28.         generatedPass=digitArray[password.length()-1]; // i set the first one here
  29.  
  30.         for(int      i=password.length()-2   ;  i>=0  ;  i-- )
  31.             generatedPass+= digitArray[i]; // now i add other digits to next to first digit
  32.  
  33.             cout << generatedPass << endl; // i put it to test how it looks
  34.     }
  35.  
  36. cout << generatedPass << endl; // gives the result
  37. return 0;
  38. }
Add Comment
Please, Sign In to add comment