Skip to content

Instantly share code, notes, and snippets.

@clamytoe
Last active April 15, 2023 14:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clamytoe/ed999b0d63f279e97f509363c7594dca to your computer and use it in GitHub Desktop.
Save clamytoe/ed999b0d63f279e97f509363c7594dca to your computer and use it in GitHub Desktop.
Small script that generates all possible 4 number pin combinations.
"""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