scripts/python/pin.py

32 lines
642 B
Python
Raw Normal View History

2022-03-18 17:59:07 +02:00
#!/usr/bin/env python
2023-10-31 10:21:46 +02:00
"""
Takes desired PIN length as an argument and generates a PIN code of that
length.
"""
2022-03-18 17:59:07 +02:00
import secrets
2023-10-10 10:16:58 +03:00
import sys
2022-03-18 17:59:07 +02:00
2023-10-31 13:34:17 +02:00
def main():
"""
This is where the magic happens.
"""
try:
desired_length = int(sys.argv[1])
except IndexError:
print("Enter a digit as an argument!")
try:
for i in range(int(desired_length)):
print(secrets.randbelow(10), end="")
# We satisfy pylint by having the variable here.
# TODO:make this a while loop?
i += 1
except NameError:
print()
2022-03-18 17:59:07 +02:00
print()
2023-10-31 13:34:17 +02:00
if __name__ == "__main__":
main()