async function findKeys(salt, hashFn) {
const candidates = [];
const keys = [];
const recentHashes = Array(1000).fill("");
for (let i = 0; keys.length < 64; i++) {
const hash = await hashFn(salt, i);
recentHashes[i % 1000] = hash;
const match = hash.match(/(\w)\1\1/);
if (match) {
candidates.push({ i, hash, char: match[1] });
}
const candidate = candidates.find((c) => c.i === i - 1000);
if (candidate) {
const pattern = `${candidate.char}{5}`;
if (recentHashes.some((h) => h.match(pattern))) {
keys.push({ i: candidate.i, hash });
}
}
}
return keys[63].i;
}