-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1_2
More file actions
49 lines (41 loc) · 1.43 KB
/
Copy path1_2
File metadata and controls
49 lines (41 loc) · 1.43 KB
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
46
47
48
49
#генерирование пароля
import argparse
import random
import string
import sys
#Парсинг
parser = argparse.ArgumentParser(description='Generate a password')
parser.add_argument('-l', '--length', type=int, help='length')
parser.add_argument('-ss', action='store_true', help='Generate password without symbols')
parser.add_argument('-sn', action='store_true', help='Generate password without numbers')
def Gen_pas(skip_s, skip_n):
if skip_s == 1:
return random.choice('0123456789')
elif skip_n == 1:
return random.choice('qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM')
else:
return random.choice('qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789')
print("Let's greate a password!",'\n',
"Press -l x, if you want to change the length of password (x - new length)", '\n',
"Press -ss if you want to skip letters", '\n',
"Press -sn if you want to skip numbers")
args = input()
if(args == ''):
password = ''
for i in range(8):
password += Gen_pas(0, 0)
print(password)
else:
args = args.split(' ')
args = parser.parse_args(args)
if args.ss and args.sn:
print("I can't generate the password!")
else:
size = 8
if args.length:
size = args.length
random.seed()
password = ''
for i in range(size):
password += Gen_pas(args.ss, args.sn)
print(password)