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
|
#include <iostream>
#include <string>
// Create some alphabet tables
const char AlphabetUpper[26] =
{
'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'
};
const char AlphabetLower[26] =
{
'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'
};
// Recursive function, keeps clocking characters
// until length is reached
void Generate(unsigned int length, std::string s)
{
if(length == 0) // when length has been reached
{
std::cout << s << "\n"; // print it out
return;
}
for(unsigned int i = 0; i < 26; i++) // iterate through alphabet
{
// Create new string with next character
// Call generate again until string has reached it's length
std::string appended = s + AlphabetLower[i];
Generate(length-1, appended);
}
}
void Crack()
{
while(1)
{
// Keep growing till I get it right
static unsigned int stringlength = 1;
Generate(stringlength, "");
stringlength++;
}
}
int main()
{
std::cerr << "Attempting to crack...";
Crack();
return 0;
}
|