Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 13 additions & 43 deletions pass.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,15 @@
#generate weak, medium, strong password
import string
import random

DIGITS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']

LOCASE_CHARACTERS = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z']

UPCASE_CHARACTERS = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'M', 'N', 'O', 'p', 'Q', 'R', 'S', 'T', 'U',
'V', 'W', 'X', 'Y', 'Z']

SYMBOLS = ['@', '#', '$', '%', '=', ':', '?', '.', '/', '|', '~', '>', '*', '(', ')']

def password_generator(p,l,s) :
random.shuffle(s)
while len(p) < l :
p += random.choice(s)
a = []
for i in p :
a.append(i)
random.shuffle(a)
p = ""
for i in a :
p += i
return p

print("Select Password Strength :\n1. Weak\n2. Medium\n3. Strong")
ch = int(input("Enter Choice : "))
if ch == 1 :
pass_length = 8
password = random.choice(LOCASE_CHARACTERS)*2 + random.choice(UPCASE_CHARACTERS)*2 #contain atleast one character from each set
combined = list((LOCASE_CHARACTERS+UPCASE_CHARACTERS))
key = password_generator(password,pass_length,combined)
elif ch == 2 :
pass_length = random.randint(9,12)
password = random.choice(DIGITS) + random.choice(LOCASE_CHARACTERS) + random.choice(UPCASE_CHARACTERS) #contain atleast one character from each set
combined = list((DIGITS+LOCASE_CHARACTERS+UPCASE_CHARACTERS))
key = password_generator(password,pass_length,combined)
else :
pass_length = 13
password = random.choice(DIGITS) + random.choice(LOCASE_CHARACTERS) + random.choice(UPCASE_CHARACTERS) + random.choice(SYMBOLS) #contain atleast one character from each set
combined = list((DIGITS+LOCASE_CHARACTERS+UPCASE_CHARACTERS+SYMBOLS))
key = password_generator(password,pass_length,combined)

print(key)
if __name__ == "__main__":
s1=string.ascii_lowercase
s2=string.ascii_uppercase
s3=string.digits
s4=string.punctuation
plen=int(input("Enter Password Length\n"))
s=[]
s.extend(list(s1))
s.extend(list(s2))
s.extend(list(s3))
random.shuffle(s)
print("".join(s[0:plen]))