diff --git a/Passgen.py b/Passgen.py new file mode 100644 index 0000000..8ae47b6 --- /dev/null +++ b/Passgen.py @@ -0,0 +1,58 @@ +from secrets import choice # Для безопасной генерации пароля +from pyperclip import copy# Для копирования в буфер обмена + +numbers=['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] +lettersB=['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', ] +lettersS=["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"] +special=[ "!", "@", "№", "#", "$", "%", "^", "|", "&", "*", "_", "-", "=", "+", "-", "/", "(", ")", "?", "{", "}", "[", "]", "~", ">", "<", "." ] + + + +if __name__ == "__main__": + lineal=int(input("Длина пароля: ")) + number=input("Использовать числа? [Д/н] ") + letterB=input("Использовать большие буквы? [Д/н] ") + letterS=input("Использовать маленькие буквы? [Д/н] ") + spec=input("Использовать спец символы? [Д/н] ") + variables=[number,letterB,letterS,spec] + for i in range(len(variables)): + if variables[i] =="Д": + variables[i]=True + if variables[i] =="н": + variables[i]=False + number,letterB,letterS,spec=variables[0],variables[1],variables[2],variables[3] + + + +def alph_generate(number,letterB,letterS,spec): + password_lst=[] # Создаём алфавит пароля + if number==True: + password_lst+=numbers + if letterB==True: + password_lst+=lettersB + if letterS==True: + password_lst+=lettersS + if spec==True: + password_lst+=special + return password_lst + +def pass_generate(password_lst,lineal): + password=[] # Создаём непосредственно пароль + for i in range(lineal): + password.append(choice(password_lst)) + password=''.join(password) + return password + +def pass_copy(copys,password): + if copys==True: + copy(password) + +if __name__ == "__main__": + password_lst=alph_generate(number,letterB,letterS,spec) + password=pass_generate(password_lst,lineal) + print(password) + if(input("Скопировать в буфер обмена? [Д/н] ")=="Д") : + copys=True + else: + copys=False + pass_copy(copys) \ No newline at end of file diff --git a/front.py b/front.py new file mode 100644 index 0000000..5f36794 --- /dev/null +++ b/front.py @@ -0,0 +1,101 @@ +from tkinter import Tk,ttk,Label,Button,Entry,IntVar,Checkbutton,END,PhotoImage +from Passgen import * +from qr import * +import os +scriptdir=os.path.abspath(__file__) +os.chdir(scriptdir.removesuffix('/front.py')) + +window = Tk() +window.geometry("350x280") +window.configure(background="#ccc") +ttk.Style().configure("TCheckbutton", padding=6, relief="flat", + background="#ccc") +window.title("Passgen by anqude") +window.tk.call('wm', 'iconphoto', window._w, PhotoImage(file='./icon.png')) +ttk.Style().configure("TButton", padding=6, relief="flat", + background="#ccc") + +label = Label(text="Passgen") +label.configure(background="#ccc", font=("", 20)) + +counter=8 +button = ttk.Button(text="Generate!",width = 39) +genqr = ttk.Button(text="Generate qr code!",width = 39) + + + + + +def copy_click(event): + name = entry.get() + pass_copy(True,name) + +def handle_click(event): + entry.delete(0, END) + try: + password=pass_generate(Checkvariables(),counter) + entry.insert(0, password) + except: + entry.insert(0, "") + +def genadiy(event): + generate_qr(entry.get()) + os.system("python3 ./qrview.py") + +def plus_click(event): + global counter + counter+=1 + label2.config(text=counter) +def minus_click(event): + global counter + if counter==1: + pass + else: + counter-=1 + label2.config(text=counter) +def Checkvariables(): + + password_lst=alph_generate(Chnumber.get(),ChletterB.get(),ChletterS.get(),Chspec.get()) + return password_lst +Chspec = IntVar() +ChletterB = IntVar() +ChletterS = IntVar() +Chnumber = IntVar() + + +button.bind("", handle_click) +genqr.bind("", genadiy) + +entry = Entry(width = 40) +CheckCpec = Checkbutton(text='Special',variable=Chspec, onvalue=True, offvalue=False, command=Checkvariables,background='#ccc') +CheckLetterB = Checkbutton(text='LETTERS',variable=ChletterB, onvalue=True, offvalue=False, command=Checkvariables,background='#ccc') +CheckLetterS = Checkbutton(text='Letters',variable=ChletterS, onvalue=True, offvalue=False, command=Checkvariables,background='#ccc') +CheckNumber = Checkbutton(text='Number',variable=Chnumber, onvalue=True, offvalue=False, command=Checkvariables,background='#ccc') +CheckNumber.select() + +plus = ttk.Button(text="+") +plus.bind("", plus_click) +minus = ttk.Button(text="-") +minus.bind("", minus_click) +Copy = ttk.Button(text="Copy!",width = 39) +Copy.bind("", copy_click) +label2 = Label(text=counter) +label2.configure(background="#ccc") + +label.pack(anchor="nw") + + +entry.place(x=14, y=35) +button.place(x=12, y=65) + +CheckCpec.place(x=12, y=110) +CheckLetterB.place(x=92, y=110) +CheckLetterS.place(x=182, y=110) +CheckNumber.place(x=262, y=110) +label2.place(x=172, y=150) +minus.place(x=12, y=140) +plus.place(x=252, y=140) +Copy.place(x=12, y=190) +genqr.place(x=12, y=230) + +window.mainloop() \ No newline at end of file diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..aea9ce5 Binary files /dev/null and b/icon.png differ diff --git a/qr.py b/qr.py new file mode 100644 index 0000000..32471db --- /dev/null +++ b/qr.py @@ -0,0 +1,7 @@ +import qrcode +def generate_qr(password): + qr = qrcode.QRCode() + qr.add_data('password: '+password) + qr.make(fit=True) + img = qr.make_image(fill_color="white", back_color="black") + img.save("qr.png") diff --git a/qrview.py b/qrview.py new file mode 100644 index 0000000..7570072 --- /dev/null +++ b/qrview.py @@ -0,0 +1,15 @@ +from tkinter import Image,Label,Tk,PhotoImage +from PIL import ImageTk, Image +import os + +window = Tk() +window.title("qr view") + +scriptdir=os.path.abspath(__file__) +os.chdir(scriptdir.removesuffix('/qrview.py')) +window.tk.call('wm', 'iconphoto', window._w, PhotoImage(file='./qr.png')) + +img = ImageTk.PhotoImage(Image.open("qr.png"),master = window) +qr = Label(window, image = img) +qr.pack() +window.mainloop()