PyPass - Source Code
PyPass - Source Code
PyPass - Source Code
#Function 1-----------------
from re import U
def insert():
webuse=str(input("For what site/app you want to create the
password: "))
lst5=['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '-', '+', '=', '`', '~', '[', '{', ']',
'}', ':', ';', "'", '"', ',', '<', '.', '>', '/', '?', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6',
'7', '8', '9', '0']
lst4=[1,2,3,4,5,6,7,8,9,0]
lst1=['!','@','#','$','%','^','&','*','(',')','_','-','+','=','`','~','[','{',']','}',':',';',',',"<",'.','
>','/','?']
lst2=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
]
lst3=[]
for i in range(len(lst2)):
b=lst2[i].upper()
lst3.append(b)
lst3
para1=int(input("How lengthy do you want your password to be (in
digits): "))
para2=int(input("how many symbols would you like to use: "))
str1=" "
str2=" "
for sym in range(para2):
ad=secrets.choice(lst1)
str1+=str(ad)+" "
str1
ab=list(str1.split())
para3=int(input("how many lowercase aplhabets you want to use: "))
for lwc in range(para3):
ac=secrets.choice(lst2)
str2+=str(ac)+" "
str2
aa=(str2.split())
for dev in range(len(aa)):
ab.append(aa[dev])
ab
para4=int(input("how many uppercase alphabets you want to use: "))
str3=' '
for dev1 in range(para4):
abc=secrets.choice(lst3)
str3+=str(abc)+" "
str3
dd=str3.split()
for dev2 in range(len(dd)):
ab.append(dd[dev2])
ab
para5=int(input("how many numbers you want in your password: "))
str4=" "
for dev3 in range(para5):
abcd=secrets.choice(lst4)
str4+=str(abcd)+" "
str4
cc=str4.split()
for dev4 in range(len(cc)):
ab.append(cc[dev4])
ab
Finalst=" "
random.shuffle(ab)
if len(ab)==para1:
for j in range(para1):
Finalst+=str(ab[j])
Finalst
print("Your password is :-\n",Finalst)
elif len(ab)<para1:
for j in range(len(ab)):
Finalst+=str(ab[j])
Finalst
for k in range(para1-len(ab)):
tt=str(secrets.choice(lst5))
Finalst+=tt
Finalst
print("Your password is :-\n",Finalst)
elif len(ab)>para1:
for j in range(para1):
tt=str(secrets.choice(ab))
Finalst+=tt
Finalst
print("Your password is :-\n",Finalst)
val=f"INSERT INTO DStorage VALUES('{webuse}',\'{Finalst}\')"
query.execute(val)
user.commit()
#Function 2-------------
def see():
query.execute("SELECT * FROM Dstorage")
a=[]
for x in query:
a.append(x)
a
if len(a)>0:
query.execute("SELECT * FROM Dstorage")
for i in query:
print(i)
elif len(a)==0:
print("No records found.\nPlease insert something first.")
#Function 3------------
def delete():
a=str(input("Enter the website for which the password has to be
deleted: "))
b=a.lower()
val=(f"DELETE FROM DStorage WHERE Website='{b}'")
query.execute(val)
user.commit()
#Function 4------------
def drop():
a=str(input("Enter the name of database: "))
a=a.lower()
b=a.split()
c=""
for i in b:
c+=i
c
user=sql.connect(host="localhost",username="root",passwd="Ad21@200
5")
query=user.cursor()
query.execute("SHOW DATABASES")
ad=[]
for i in query:
ad.append(str(i))
ad
if (f"(\'{c}\',)") in ad:
val=(f"DROP DATABASE {c}")
query.execute(val)
user.commit()
print("The database have been deleted.")
elif (f"(\'{c}\',)") not in ad:
print("The database you entered doesn't exist.")
print("Here the list of your databases:-\n",ad)
print("Try again.")
#Function 5
def update():
a=str(input("For which site ? "))
a=a.lower()
print("1) Create one or 2) Have your own password")
updch=int(input("Enter your choice (1 Or 2): "))
if updch== 1 :
lst5=['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '-', '+', '=', '`', '~', '[',
'{', ']', '}', ':', ';', "'", '"', ',', '<', '.', '>', '/', '?', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '0']
lst4=[1,2,3,4,5,6,7,8,9,0]
lst1=['!','@','#','$','%','^','&','*','(',')','_','-','+','=','`','~','[','{',']','}',':',';',',',"<",'.','
>','/','?']
lst2=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
]
lst3=[]
for i in range(len(lst2)):
b=lst2[i].upper()
lst3.append(b)
lst3
para1=int(input("How lengthy do you want your password to be
(in digits): "))
para2=int(input("how many symbols would you like to use: "))
str1=" "
str2=" "
for sym in range(para2):
ad=secrets.choice(lst1)
str1+=str(ad)+" "
str1
ab=list(str1.split())
para3=int(input("how many lowercase aplhabets you want to
use: "))
for lwc in range(para3):
ac=secrets.choice(lst2)
str2+=str(ac)+" "
str2
aa=(str2.split())
for dev in range(len(aa)):
ab.append(aa[dev])
ab
para4=int(input("how many uppercase alphabets you want to
use: "))
str3=' '
for dev1 in range(para4):
abc=secrets.choice(lst3)
str3+=str(abc)+" "
str3
dd=str3.split()
for dev2 in range(len(dd)):
ab.append(dd[dev2])
ab
para5=int(input("how many numbers you want in your
password: "))
str4=" "
for dev3 in range(para5):
abcd=secrets.choice(lst4)
str4+=str(abcd)+" "
str4
cc=str4.split()
for dev4 in range(len(cc)):
ab.append(cc[dev4])
ab
Finalst=" "
random.shuffle(ab)
if len(ab)==para1:
for j in range(para1):
Finalst+=str(ab[j])
Finalst
print("Your password is :-\n",Finalst)
elif len(ab)<para1:
for j in range(len(ab)):
Finalst+=str(ab[j])
Finalst
for k in range(para1-len(ab)):
tt=str(secrets.choice(lst5))
Finalst+=tt
Finalst
print("Your password is :-\n",Finalst)
elif len(ab)>para1:
for j in range(para1):
tt=str(secrets.choice(ab))
Finalst+=tt
Finalst
upd=f"UPDATE Dstorage SET Password='{Finalst}' WHERE
Website='{a}'"
query.execute(upd)
user.commit()
print("A new Password has been created and updated.")
elif updch == 2 :
b=str(input("Enter the new password (Without spaces): "))
upd=(f"UPDATE Dstorage SET Password='{b}' WHERE
Website='{a}'")
query.execute(upd)
user.commit()
print("Record successfully updated.")
else:
print("Invalid Choice !")
print("Try again")
#Modules-----------------
import time
import mysql.connector as sql
import random
import secrets
#Main Program---------------
print("Welcome to the PyPass 🔒🔑\nHere we provide you with secure
passwords for your use.")
cont="y"
while cont=="y":
print("i) Press 1 to register (for new users).\nii) Press 2 to log in (for
existing users).\niii) Press 3 to drop a database.\niv) Press 4 to exit.")
time.sleep(1)
choice=int(input("Enter your choice : "))
if choice == 1:
print("To start, let's create a database to store your data :-")
time.sleep(0.60)
DB=str(input("Give a name for your database: "))
a=""
DB=DB.lower().split()
for i in DB:
a+=str(i)
a
webuse=str(input("For what site/app you want to create the
password: "))
webuse=webuse.lower()
user=sql.connect(host="localhost",username="root",passwd="Ad21@200
5")
query=user.cursor()
lst7=[]
query.execute("SHOW DATABASES")
for i in query:
lst7.append(str(i))
lst7
if (f"(\'{a}\',)") in lst7:
print("The database already eixsts.")
print("Try again")
time.sleep(1)
cont=input("Want to continue(Y/N): ")
cont=cont.lower()
elif (f"(\'{a}\',)") not in lst7:
query.execute(f"CREATE DATABASE {a}")
query.execute(f"USE {a}")
query.execute("CREATE TABLE Dstorage(Website
VARCHAR(100), Password VARCHAR(100))")
lst5=['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '-', '+', '=', '`',
'~', '[', '{', ']', '}', ':', ';', "'", '"', ',', '<', '.', '>', '/', '?', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2',
'3', '4', '5', '6', '7', '8', '9', '0']
lst4=[1,2,3,4,5,6,7,8,9,0]
lst1=['!','@','#','$','%','^','&','*','(',')','_','-','+','=','`','~','[','{',']','}',':',';',"'",'"',',',"
<",'.','>','/','?']
lst2=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
]
lst3=[]
for i in range(len(lst2)):
b=lst2[i].upper()
lst3.append(b)
lst3
para1=int(input("How lengthy do you want your password
to be (in digits): "))
para2=int(input("how many symbols would you like to use:
"))
str1=" "
str2=" "
for sym in range(para2):
ad=secrets.choice(lst1)
str1+=str(ad)+" "
str1
ab=list(str1.split())
para3=int(input("how many lowercase aplhabets you want
to use: "))
for lwc in range(para3):
ac=secrets.choice(lst2)
str2+=str(ac)+" "
str2
aa=(str2.split())
for dev in range(len(aa)):
ab.append(aa[dev])
ab
para4=int(input("how many uppercase alphabets you want
to use:"))
str3=' '
for dev1 in range(para4):
abc=secrets.choice(lst3)
str3+=str(abc)+" "
str3
dd=str3.split()
for dev2 in range(len(dd)):
ab.append(dd[dev2])
ab
para5=int(input("how many numbers you want in your
password: "))
str4=" "
for dev3 in range(para5):
abcd=secrets.choice(lst4)
str4+=str(abcd)+" "
str4
cc=str4.split()
for dev4 in range(len(cc)):
ab.append(cc[dev4])
ab
Finalst=" "
random.shuffle(ab)
if len(ab)==para1:
for j in range(para1):
Finalst+=str(ab[j])
Finalst
print("Your password is :-\n",Finalst)
elif len(ab)<para1:
for j in range(len(ab)):
Finalst+=str(ab[j])
Finalst
for k in range(para1-len(ab)):
tt=str(secrets.choice(lst5))
Finalst+=tt
Finalst
print("Your password is :-\n",Finalst)
elif len(ab)>para1:
for j in range(para1):
tt=str(secrets.choice(ab))
Finalst+=tt
Finalst
print("Your password is :-\n",Finalst)
val=(f"INSERT INTO DStorage
VALUES('{webuse}','{Finalst}')")
query.execute(val)
user.commit()
print("Thank you for Using Pypass😊")
print("You and your data has been successfully registered
in our server for your future use.")
print("For further use please log in to your account.")
cont=input("Want to continue(Y/N): ")
cont=cont.lower()
elif choice==2:
ans="y"
while ans=="y":
print("*"*30)
print(" WELCOME TO THE LOGIN PAGE")
print("*"*30)
ab=str(input("Enter the name of your database: "))
ab=ab.lower()
cd=ab.split()
bc=""
for i in cd:
bc+=str(i)
bc
user=sql.connect(host="localhost",username="root",passwd="Ad21@200
5")
query=user.cursor()
query.execute("SHOW DATABASES")
a=[]
for i in query:
a.append(str(i))
a
if (f"(\'{bc}\',)") in a:
query.execute(f"USE {bc}")
print("What do you want to do\n1)Insert a new
password\n2)See your saved passwords\n3)Delete a existing password\
n4)Update an existing password\n5)To log out.")
choice=int(input("Enter your choice: "))
if choice==1 and type(choice)==int:
insert()
print("The data have been entered.")
elif choice==2 and type(choice)==int:
print("Here is your data:")
see()
elif choice==3 and type(choice)==int:
delete()
print("The record has been deleted.")
elif choice==4 and type(choice)==int:
update()
elif choice==5 and type(choice)==int:
break
print("Thank you for your time.")
print("Exiting....")
time.sleep(1)
elif (f"(\'{bc}\',)") not in a :
print("No such records found.")
ask=str(input("Did you forget the name of your
database (Y/N): "))
if ask=="Y" or ask=="y":
print("Here is a list of all the databases:\n",a)
time.sleep(1)
print("Try again.")
else:
print("Try again.")
time.sleep(1)
ans=input("Want to continue(Y/N): ")
ans=ans.lower()
else:
print("Thank you for your time.")
print("Exiting....")
time.sleep(1)
break
elif choice==3:
drop()
cont=str(input("Want to continue (Y/N): "))
cont.lower()
elif choice==4:
print("Thank you for your time.")
print("Hope we will see you soon.....👋🏻")
print("Exiting......")
time.sleep(1)
break
else:
print("Exiting....")
time.sleep(1)
#End of the program-----------