1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
#include <iostream>
#include <string>
int main()
{ //user is told to enter a password.
std:: cout << "enter a password for me to crack: "<<std::endl;
//this is variable pass
std:: string pass=;
// the user enters a password that is stored as variable pass.
std:: cin >> pass;
//this is a letter and number table used to generate the passwords for guessing.
char Tab[62] ={
'0','1','2','3','4','5','6','7','8','9',
'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','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',
};
//these int's are going through the table.
//for every int there is one more letter in the password.
//when one int goes all the way through the table it adds one to the next int in the the sequence.
int numa = 0;
int numb = 0;
int numc = 0;
int numd = 0;
int nume = 0;
int numf = 0;
int numg = 0;
int numh = 0;
int numi = 0;
int numj = 0;
// this bool is for checking if we guessed the correct password
bool Check =false;
//while the bool check is false id will do the action.
//when we guess the password the bool will be true and will stop doing the action.
std:: string stregnth = while(Check = false){
//we add more letters to the password until we get it right.
numa++;
if(numa>62){
numa=0;
numb++;
if (numb>62){
numb=0;
numc++;
if(numc>62){
numc=0;
numd++;
if(numd>62){
numd=0;
nume++;
if(nume>62){
nume=0;
numf++;
if(numf>62){
numf=0;
numg++;
if(numg>62){
numg=0;
numh++;
if(numh>62){
numh=0;
numi++;
if(numi>62){
numi=0;
numj++;
if(numj>62){
//the password was longer than 10 characters so we couldn't find it.
Check = true;
//we tell the user the error that occurred.
std::cout<<"Error password too long!!!\nTry again!!!";
};
};
};
};
};
};
};
};
};
};
};
//this is where the numbers and letters are combined to make the passwords.
std::string guess =taB[numj]+taB[numi]+taB[numh]+taB[numg]+taB[numf]+taB[nume]+taB[numd]+taB[numc]+taB[numb]+taB[numa];
//this wrights out the progress that we have made so far.
std:: cout <<guess;
//if we guessed the right password then stop guessing and tell the user our guess.
if (pass == guess){
Check = true;
std::cout<< "Your password is: "<< guess;
};
return 0;
} ;
|