-
Notifications
You must be signed in to change notification settings - Fork 6
/
PasswordGeneratorV2
61 lines (46 loc) · 1.92 KB
/
PasswordGeneratorV2
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
50
51
52
53
54
55
56
57
58
59
60
61
# This is a sample Python script that takes a users details and automatically generates a password.
# different functions can be created or modified
import random
import string
## Characters to generate password from
alphabets = list(string.ascii_letters)
digits = list(string.digits)
symbols = list("!@#$%^&*()/|;'`~-_")
special_characters = list(string.ascii_letters + string.digits + "!@#$%^&*()/|;'`~-_")
# What if we did this with a customisable length
def password_gen():
# length of password entered by user
length = int(input("Enter password length: "))
## number of character types
alphabets_count = int(input("Enter alphabets count in password: "))
digits_count = int(input("Enter digits count in password: "))
symbols_count = int(input("Enter special characters count in password: "))
characters_count = alphabets_count + digits_count + symbols_count
# A normal password should contain at-least 8 characters
# Let's try to specify it
if characters_count <= 7:
return print("Enter a number above 8")
elif length >= 8:
print("What where you waiting for goat")
# shuffling the special_characters
random.shuffle(special_characters)
# initializing the password
password = []
# picking random alphabets
for i in range(alphabets_count):
password.append(random.choice(alphabets))
# picking random digits
for i in range(digits_count):
password.append(random.choice(digits))
# picking random alphabets
for i in range(symbols_count):
password.append(random.choice(symbols))
# shuffling the resultant password
random.shuffle(password)
# converting the list to string
# printing the list
print("".join(password))
return password_gen()
else:
return print("Oga is everything alright with you?😂")
password_gen()