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
|
|
|
|
|
|
|
|
2023-10-31 12:34:17 +01: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 16:59:07 +01:00
|
|
|
print()
|
2023-10-31 12:34:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|