51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
#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;
|
|
};
|
|
|
|
/// returns true when all threads finished
|
|
bool DisplayThreadInfo();
|
|
|
|
|
|
void BruteMain(const swbf::BruteforceWorker::Options& options);
|
|
|
|
} // namespace swbf
|