Skip to content

Commit

Permalink
password generator
Browse files Browse the repository at this point in the history
  • Loading branch information
R3DHULK authored Nov 21, 2022
1 parent 4dcbead commit 93ec0f7
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions random-pass-gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import string,random

def generate(n):

"""
This function will take n as password length then generate final string which has letters,digits and puntuation
then convert that string into list
then uses random.shuffle to shuffle that list
initiale another list in which we store our password
then iterate a loop to password length so it can save characters through random.choice in pw_list
shuffle pw_list for more randomness
converts pw_list into string password.
"""

s1 = str(input("\033[92m [*] Enter Name : "))
s2=str(input("\033[92m [*] Enter Name : "))
s3=str(input("\033[92m [*] Enter Name : "))

final = s1+s2+s3

l1 = list(final)
random.shuffle(l1)

pw_list = []

i=0
while i<n:
pw_list.extend(random.choice(l1))
i+=1

random.shuffle(pw_list)
password = ''.join(pw_list)
print("\033[91m [+] Your Password Is "+password)


if __name__ == "__main__":
c="y"
while c=="y":
try:
n = int(input("\033[92m [+] Enter desired length of password: "))
generate(n)
c=input("\033[96m [*] Do you want to generate another password? (y/n): ").lower()
except:
print("\033[91m\n [*] Please Enter integer value for length")



0 comments on commit 93ec0f7

Please sign in to comment.