Skip to content

Commit

Permalink
Allow to set a new target for SixCharactersRecovery
Browse files Browse the repository at this point in the history
  • Loading branch information
kimci86 committed Aug 10, 2024
1 parent cc50681 commit 342b661
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/password.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ template <typename Derived /* must implement onSolutionFound() method */>
class SixCharactersRecovery
{
public:
SixCharactersRecovery(const Keys& target, const std::vector<std::uint8_t>& charset4,
const std::vector<std::uint8_t>& charset5)
void setTarget(const Keys& target, const std::vector<std::uint8_t>& charset4,
const std::vector<std::uint8_t>& charset5)
{
// initialize target X, Y and Z values
x[6] = target.getX();
Expand All @@ -31,6 +31,8 @@ class SixCharactersRecovery
z[i - 1] = Crc32Tab::crc32inv(z[i], msb(y[i]));

// precompute possible Z0[16,32) and Z{-1}[24,32)
z0_16_32.reset();
zm1_24_32.reset();
for (const auto p5 : charset5)
{
x[5] = Crc32Tab::crc32inv(x[6], p5);
Expand Down Expand Up @@ -140,13 +142,13 @@ class BruteforceRecovery : public SixCharactersRecovery<BruteforceRecovery>
public:
BruteforceRecovery(const Keys& keys, const std::vector<std::uint8_t>& charset, std::vector<std::string>& solutions,
std::mutex& solutionsMutex, bool exhaustive, Progress& progress)
: SixCharactersRecovery{keys, charset, charset}
, charset{charset}
: charset{charset}
, solutions{solutions}
, solutionsMutex{solutionsMutex}
, exhaustive{exhaustive}
, progress{progress}
{
setTarget(keys, charset, charset);
}

void search(std::size_t length)
Expand Down

0 comments on commit 342b661

Please sign in to comment.