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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <cmath>
using namespace std;
string pair1,pair2,pair3,pair4,total,dash,crack1,crack2,crack3,crack4;
bool pairone = true,pairtwo = true,pairthree = true, pairfour = true;
string singles[45] = {"1","2","3","4","5","6","7","8","9","0",
"q","w","e","r","t","y","u","i","o",
"p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m",
"!","£","$","%","^","&","*","(",")"};
string getrandpair ()
{
string pair,p1,p2;
int slctr,slctr2;
slctr = 1+(rand()%44);
slctr2 = 1+(rand()%44);
p1 = singles [slctr];
p2 = singles [slctr2];
return pair = p1+p2;
}
bool crackpair (string &pair, string &crack, bool &pass)
{
string temppair, part1, part2, part3,part4,empty1;
for (int a = 0; a<45 ; a++)
{
part1 = singles [a];
for (int b = 0; b<45 ; b++)
{
part2 = singles [b];
for (int c = 0; c<45 ; c++)
{
part3 = singles [c];
for (int d = 0;d<45;d++ )
{
part4 = singles [d];
temppair = part1+part2+part3+part4;
cout << temppair;
if (pair == temppair)
{
crack = temppair;
return pass =false;
system ("cls");
break;
}
}
if (pair == temppair)
break;
}
if (pair == temppair)
break;
}
if (pair == temppair)
break;
}
}
int main ()
{
system ("color a");
srand(time(0));
dash = "-";
int refresh;
bool quit = true, restart = true;
while (quit != false)
{
cout << "type 1 to create new code or type 2 to quit "<<endl;
cin >> refresh;
switch (refresh)
{
case 2:
quit = false;
break;
case 1:
while (restart != false)
{
pair1 = getrandpair();
pair2 = getrandpair();
pair3 = getrandpair();
pair4 = getrandpair();
cout << pair1<<"-"<<pair2<<"-"<<pair3<<"-"<<pair4<<endl;
cout << "press 1 to begin decoding and 2 to quit"<< endl;
cin >> refresh;
switch (refresh)
{
case 2:
restart = false;
break;
case 1:
while (restart != false)
{
while (pairone != false)
{
crackpair(pair1,crack1,pairone);
}
restart = false;
}
break;
}
restart = true;
break;
cout << "the code was; "<< crack1<<"restart? y/n"<<endl;
}
}
}
return 0;
}
|