scripts/python/pin.py

20 lines
393 B
Python
Raw Normal View History

2022-03-18 16:59:07 +01:00
#!/usr/bin/env python
2023-10-31 09:21:46 +01:00
"""
Takes desired PIN length as an argument and generates a PIN code of that
length.
"""
2022-03-18 16:59:07 +01:00
import secrets
2023-10-10 09:16:58 +02:00
import sys
2022-03-18 16:59:07 +01:00
try:
2023-04-06 11:03:10 +02:00
wantedCount = int(sys.argv[1])
2022-03-18 16:59:07 +01:00
except IndexError as noarg:
2023-04-06 11:03:10 +02:00
print("Enter a digit as an argument!")
2022-03-18 16:59:07 +01:00
try:
2023-04-06 11:03:10 +02:00
for i in range(int(wantedCount)):
2023-05-18 09:06:16 +02:00
print(secrets.randbelow(10), end="")
2022-03-18 16:59:07 +01:00
except NameError as noWantedCount:
print()
print()