2023-08-22 04:30:34 -04:00
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace swbf {
|
|
|
|
constexpr static auto MAX_CODE_LENGTH = 8;
|
|
|
|
constexpr static auto THREAD_COUNT = 26; // this is a-z
|
|
|
|
|
|
|
|
/// private structure
|
|
|
|
struct ThreadInfoData;
|
|
|
|
|
|
|
|
/// Per-thread worker for brute-forcing
|
|
|
|
struct BruteforceWorker {
|
|
|
|
/// Options for the worker.
|
|
|
|
struct Options {
|
|
|
|
/// The target hash to find matches for.
|
|
|
|
std::uint32_t targetHash;
|
|
|
|
|
|
|
|
/// If `startLength` should be treated as the code length.
|
|
|
|
bool exact;
|
|
|
|
|
|
|
|
std::uint32_t startLength;
|
|
|
|
std::uint32_t endLength;
|
|
|
|
};
|
|
|
|
|
|
|
|
BruteforceWorker(unsigned tid, const Options& options);
|
|
|
|
|
|
|
|
/// Public-facing driver function - the thread pool runs this.
|
|
|
|
void Bruteforce(char prefix);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void BruteforceForLength(char prefix, std::uint32_t length);
|
|
|
|
|
|
|
|
void CopyDisplayData();
|
|
|
|
ThreadInfoData& DisplayData();
|
|
|
|
|
|
|
|
Options options;
|
|
|
|
|
|
|
|
unsigned threadIndex;
|
|
|
|
std::string test_buffer;
|
|
|
|
std::uint32_t hash;
|
|
|
|
};
|
|
|
|
|
2023-08-22 05:03:49 -04:00
|
|
|
/// returns true when all threads finished
|
|
|
|
bool DisplayThreadInfo();
|
|
|
|
|
|
|
|
|
|
|
|
void BruteMain(const swbf::BruteforceWorker::Options& options);
|
|
|
|
|
2023-08-22 04:30:34 -04:00
|
|
|
} // namespace swbf
|