i'm having a problem with a program intended to "crack passwords" but not really.. this will never be implemented, i just thought it'd be a cool project to get to know c++.
how it works:
it recognizes 93 chars (93 because that's the number of special chars and letters you would expect to find in a simple-ish password)
it finds total number of possible password combinations based on the formula
93^length of the password
then, by using a for loop, it counts up from 0 to the number of combinations possible.
inside that for loop is another for loop that sets the value of each node of the array by iterating through and using this thought
array[0] will equal number/(93^length)
array[i] will equal (number%(93^length)/(93^(length-i)))
the problem: the output isn't even giving me a value after the first node in the array, it's only working correctly for the first node
i know this method works, but maybe my syntax is messed up. i've tinkered for hours with no solution. please help :)
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
|
#include <iostream>
#include <string>
#include <array>
#include <cmath>
using namespace std;
int main(){
int* passArray2 = NULL;
int number, numRemain, findRemain, length;
double percentDone;
double availChars = 93;
cout << "Enter the length of the password: ";
cin >> length;
passArray2 = new int[length];
for(int z = 0; z < length; z++){
passArray2[z] =0;
}
double possible = pow(availChars,length);
for(number = 0; number <= possible; number ++){
percentDone = 100*number/possible;
cout<< endl;
for(int i = 0; i < length; i++){
findRemain = pow(availChars,(length-(i+1)));
numRemain = number % findRemain;
if(i==0){
passArray2[i] = number/findRemain;
cout << passArray2[i];
}else{
passArray2[i] = numRemain/findRemain;
cout << passArray2[i];
}
}
cout << " " << percentDone << "%" << endl;
//system("pause");
}
system("pause");
}
|
and i realize that my code is very sloppy right now. that's what happens when you change every little thing for a couple hours haha
thanks for any help!