-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpypass
executable file
·45 lines (41 loc) · 1.31 KB
/
pypass
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python3
import argparse
import random
import string
# Create argument parser.
parser = argparse.ArgumentParser()
parser.add_argument("--letters", default = string.ascii_letters)
parser.add_argument("--digits", default = string.digits)
parser.add_argument("--punctuation", default = string.punctuation)
parser.add_argument("--length", type = int, default = 128)
parser.add_argument("--count", type = int, default = 10)
parser.add_argument("--silent", action = "store_true", default = False)
# Get arguments.
arguments = parser.parse_args()
letters = arguments.letters
digits = arguments.digits
punctuation = arguments.punctuation
length = arguments.length
count = arguments.count
silent = arguments.silent
# Check the silence.
if not silent:
# Print arguments.
print(f"Letters: {letters}")
print(f"Digits: {digits}")
print(f"Punctuation: {punctuation}")
print(f"Length: {length}")
print(f"Count: {count}")
print()
# Generate passwords.
for _ in range(count):
# Concatenate characters.
characters = list(letters + digits + punctuation)
# Shuffle characters.
random.shuffle(characters)
# Pick random characters.
choices = random.choices(characters, k = length)
# Join password.
password = "".join(choices)
# Print password.
print(password)