Skip to content

Instantly share code, notes, and snippets.

@jason-s13r
Last active Mar 11, 2022
Embed
What would you like to do?
NZTA Toll Road account system has an incredibly stupid PIN criteria system for the username & pin sign in. Generate all possible PINs for the NZTA Toll Road account. There are only 72500 valid PINs available.
const start = new Date();
const characters = 'abcdefghijklnopqrstuvwxyz0123456789';
const valid = new Set();
const invalid = new Set();
for (let a = 0; a < characters.length; a++) {
for (let b = 0; b < characters.length; b++) {
for (let c = 0; c < characters.length; c++) {
for (let d = 0; d < characters.length; d++) {
const word = characters[a] + characters[b] + characters[c] + characters[d];
const hasLetter = /[a-z]/.test(word);
const hasNumber = /[0-9]/.test(word);
const numberInPosition = /(.\d..)|(..\d.)/.test(word);
if (hasLetter && hasNumber && numberInPosition) {
valid.add(word);
} else {
invalid.add(word);
}
}
}
}
}
const end = new Date();
const time = (end.getTime() - start.getTime());
console.log({
valid,
invalid,
time: time + 'ms'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment