Skip to content

Commit

Permalink
Shuffle external mode: Optimization: Don't rewrite unchanged part
Browse files Browse the repository at this point in the history
  • Loading branch information
solardiz committed May 27, 2024
1 parent 39eb3e3 commit ba46368
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions run/john.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3971,7 +3971,7 @@ void next()

# Shuffle (try all permutations of) characters in each short input word
[List.External:Shuffle]
int max_length, unique, length, base[0x80], id[0x80], jd[0x80];
int max_length, unique, length, base[0x80], id[0x80], jd[0x80], unseen[0x80];

void init()
{
Expand All @@ -3998,11 +3998,13 @@ void new()
}
}
}

unseen = 0;
}

void next()
{
int unseen, c, i, j, k;
int prev_unseen, c, i, j, k;

if ((i = length) <= max_length)
while (i--) {
Expand All @@ -4011,17 +4013,21 @@ void next()
continue;
}

unseen = i = -1;
prev_unseen = -1;
if (!unseen)
unseen = i = -1;
else if (i--)
prev_unseen = unseen[i];
while (++i < length) {
/* Skip id[i] previously unseen char indices */
j = -1;
k = id[i];
while (k >= 0)
if (unseen & (1 << ++j))
if (prev_unseen & (1 << ++j))
k--;
if (unique) {
word[i] = base[j];
unseen &= ~(1 << j);
unseen[i] = prev_unseen &= ~(1 << j);
continue;
}
/* Same chars must only appear in one order */
Expand All @@ -4036,7 +4042,7 @@ void next()
if (k < i)
break;
word[i] = c;
unseen &= ~(1 << (jd[i] = j));
unseen[i] = prev_unseen &= ~(1 << (jd[i] = j));
}

if (i >= length) /* Not a dupe */
Expand Down

0 comments on commit ba46368

Please sign in to comment.