mirror of
https://gitea.blesmrt.net/mikaela/scripts.git
synced 2024-11-29 22:59:22 +01:00
32 lines
642 B
Python
Executable File
32 lines
642 B
Python
Executable File
#!/usr/bin/env python
|
|
"""
|
|
Takes desired PIN length as an argument and generates a PIN code of that
|
|
length.
|
|
"""
|
|
import secrets
|
|
import sys
|
|
|
|
|
|
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()
|
|
print()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|