skip420

generate_random_4_digits

Mar 15th, 2021 (edited)
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. """
  2. write a script that produces all possible 4-digit numbers (0000...9999),
  3. then put them into a random order and save the output into a text file.
  4. """
  5. def gen_pins():
  6.     """Generates the pins"""
  7.     pins = {str(n).zfill(4) for n in range(0, 10000)}
  8.     return pins
  9.  
  10.  
  11. def save_pins(pins, filename):
  12.     """Saves the pins to a text file"""
  13.     with open(filename, 'w') as file:
  14.         for pin in pins:
  15.             file.write(f'{pin}\n')
  16.  
  17.  
  18. def main():
  19.     """Runs the script"""
  20.     filename = 'leaked_pins.txt'
  21.     pins = gen_pins()
  22.     save_pins(pins, filename)
  23.     print(f'Generated: {filename}')
  24.  
  25.  
  26. if __name__ == '__main__':
  27.     main()
  28.  
Add Comment
Please, Sign In to add comment