Last active
April 15, 2023 14:54
-
-
Save clamytoe/ed999b0d63f279e97f509363c7594dca to your computer and use it in GitHub Desktop.
Small script that generates all possible 4 number pin combinations.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""pins.py | |
Small script that generates all possible 4 number | |
pin combinations. Inspired by @ThePracticalDev's tweet challenge: | |
https://twitter.com/thepracticaldev/status/1000191076106465281?s=21 | |
Challenge Alert!! | |
Write a script that produces all possible 4-digit numbers (0000...9999), | |
then put them into a random order and save the output into a text file. | |
""" | |
def gen_pins(): | |
"""Generates the pins""" | |
pins = {str(n).zfill(4) for n in range(0, 10000)} | |
return pins | |
def save_pins(pins, filename): | |
"""Saves the pins to a text file""" | |
with open(filename, 'w') as file: | |
for pin in pins: | |
file.write(f'{pin}\n') | |
def main(): | |
"""Runs the script""" | |
filename = 'leaked_pins.txt' | |
pins = gen_pins() | |
save_pins(pins, filename) | |
print(f'Generated: {filename}') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment