Skip to content

Commit

Permalink
Update algorithim
Browse files Browse the repository at this point in the history
  • Loading branch information
hydrophobis committed Mar 27, 2024
1 parent b199db9 commit f23f6fe
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 1 deletion.
Binary file modified a.out
Binary file not shown.
1 change: 1 addition & 0 deletions pw.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// 13500 Guesses Per Second
// aid! 604.345926 in 10.3 Million
#include <string>
#include <iostream>
#include <cstdlib>
Expand Down
43 changes: 43 additions & 0 deletions pwa.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// 7.4 Million Guesses Per Second
// Aid! 0.7720547s in 630967
#include <iostream>
#include <string>
#include <vector>
Expand Down Expand Up @@ -32,20 +34,61 @@ void generateCombinations(const string& charSet, int maxLength, const string& pa
// Remove the last character to try the next combination
currentString.pop_back();
}

cout << currentString << "\n";
}

void generateCombinations2(const string& charSet, int maxLength, const string& password, string& currentString, int& guesses) {
static auto start = chrono::steady_clock::now();

if (currentString == password) {
auto end = chrono::steady_clock::now();
chrono::duration<double> elapsed_seconds = end - start;
cout << "Found " << password << " with " << guesses << " guesses" << " in " << elapsed_seconds.count() << " seconds" << endl;
exit(0);
}

for (char c : charSet) {
// Ensure the first character is a capital letter
if (currentString.empty() && !isupper(c)) {
continue;
}

if (currentString.length() != 1 && !islower(c)){
continue;
}

currentString.push_back(c);
++guesses;

// Check if the length of the currentString is within the maxLength limit
if (currentString.length() <= maxLength) {
generateCombinations(charSet, maxLength, password, currentString, guesses);
}

// Remove the last character to try the next combination
currentString.pop_back();
}

cout << currentString << "\n";
}

int main() {
string charSet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-_=+[]{}|,',.<>?~";

string password;
int maxLength;
bool algorithim;

cout << "Password: ";
cin >> password;

cout << "Length: ";
cin >> maxLength;

cout << "0 for Aa11! format, 1 for Aa1!1";
cin >> algorithim;

string currentString;
int guesses = 0;

Expand Down
1 change: 1 addition & 0 deletions pwr.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// 6.3 Million Guesses Per Second
// Aid! 0.949004s in 5.7 Million
#include <iostream>
#include <string>
#include <vector>
Expand Down
3 changes: 2 additions & 1 deletion pws.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// 101 Thousand Guesses Per Second
// 101.4 Thousand Guesses Per Second
// aid! 0.814276s
#include <iostream>
#include <string>
#include <vector>
Expand Down
52 changes: 52 additions & 0 deletions pwt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Test file, No output
// 49.2 Million Guesses Per Second
// aid! 0.116392s in 5.7 Million Guesses
#include <iostream>
#include <string>
#include <vector>
#include <chrono>

using namespace std;

string currentString;
int guesses = 0;

// Function to generate combinations using recursive backtracking
void generateCombinations(string charSet, int maxLength, string password) {
static auto start = chrono::steady_clock::now();

if (currentString == password) {
auto end = chrono::steady_clock::now();
chrono::duration<double> elapsed_seconds = end - start;
cout << "Found " << password << " with " << guesses << " guesses" << " in " << elapsed_seconds.count() << " seconds" << endl;
exit(0);
}

for (char c : charSet) {
currentString.push_back(c);
++guesses;

if (currentString.length() <= maxLength) {
generateCombinations(charSet, maxLength, password, currentString, guesses);
}

currentString.pop_back();
}
}

int main() {
string charSet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-_=+[]{}|,',.<>?~";

string password;
int maxLength;

cout << "Password: ";
cin >> password;

cout << "Length: ";
cin >> maxLength;

generateCombinations(charSet, maxLength, password);

return 0;
}

0 comments on commit f23f6fe

Please sign in to comment.