Skip to content

Instantly share code, notes, and snippets.

@jason-s13r
Last active April 27, 2023 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jason-s13r/27dd1f5033a91314ef9380bf372f5534 to your computer and use it in GitHub Desktop.
Save jason-s13r/27dd1f5033a91314ef9380bf372f5534 to your computer and use it in GitHub Desktop.
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 725000 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