August 2024
Intermediate to advanced
516 pages
11h 47m
English
You’re a hacker (an ethical one, of course) who’s trying to figure out someone’s password. You decide on a brute-force approach and write some code that produces every possible string of a given length. Here’s the code you whipped up:
| | function everyPassword(length) { |
| | let string = 'a'.repeat(length); |
| | console.log(string); |
| | |
| | while (string !== 'z'.repeat(length)) { |
| | let stringToBase36 = parseInt(string, 36); |
| | stringToBase36 += 1; |
| | string = (stringToBase36.toString(36)).replace(/0/g, 'a'); |
| | console.log(string); |
| | } |
| | } |
There’s a bit of complicated magic in this code, which thankfully, we don’t need to understand at this time. That’s because we’re not going to focus on how this code works, but rather what ...
Read now
Unlock full access