Name: jfx 2011-02-23 15:05
Hi, could anybody c++ programmer please tell me how following code should look like, if it shouldnt be in a function.
I need it seperate so i can stop it when it found a specific combination/password.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#include <iostream>
#include <string>
#include <fstream>
#include <windows.h>
using namespace std;
char str[255];
int many;
ofstream file ("list.txt");
void swap(char* first, char* second)
{
char ch = *second;
*second = *first;
*first = ch;
}
int permute(char* set, int begin, int end)
{
int i;
int range = end - begin;
if (range == 1) {
file<<set<<endl;
cout << set << endl;
} else {
for(i=0; i<range; i++) {
swap(&set[begin], &set[begin+i]); //initial swap
permute(set, begin+1, end); //recursion
swap(&set[begin], &set[begin+i]); //swap back
}
}
return 0;
}
int main()
{
SetConsoleTitleA("Rainbow Attack");
std::cout << "Rainbow Attack 4" << endl;
cout << "Set: ";
cin.getline(str, 255); //take string
permute(str, 0, strlen(str)); //permutate the string
cout << endl << "Done" << endl;
file.close();
return 0;
}
I need it seperate so i can stop it when it found a specific combination/password.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#include <iostream>
#include <string>
#include <fstream>
#include <windows.h>
using namespace std;
char str[255];
int many;
ofstream file ("list.txt");
void swap(char* first, char* second)
{
char ch = *second;
*second = *first;
*first = ch;
}
int permute(char* set, int begin, int end)
{
int i;
int range = end - begin;
if (range == 1) {
file<<set<<endl;
cout << set << endl;
} else {
for(i=0; i<range; i++) {
swap(&set[begin], &set[begin+i]); //initial swap
permute(set, begin+1, end); //recursion
swap(&set[begin], &set[begin+i]); //swap back
}
}
return 0;
}
int main()
{
SetConsoleTitleA("Rainbow Attack");
std::cout << "Rainbow Attack 4" << endl;
cout << "Set: ";
cin.getline(str, 255); //take string
permute(str, 0, strlen(str)); //permutate the string
cout << endl << "Done" << endl;
file.close();
return 0;
}