Big update
now GUI is one window, qr on center,design improve
This commit is contained in:
parent
7ac42e1f58
commit
7a6b618168
@ -1,35 +1,8 @@
|
|||||||
from secrets import choice # Для безопасной генерации пароля
|
|
||||||
from pyperclip import copy# Для копирования в буфер обмена
|
from pyperclip import copy# Для копирования в буфер обмена
|
||||||
from logics.entropy import get_entopy
|
from logics.entropy import get_entopy
|
||||||
from logics.qr import generate_qr_text
|
from logics.qr import generate_qr_text
|
||||||
numbers=['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
|
from logics.generate import alph_generate,pass_generate
|
||||||
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=[ "!", "@", "№", "#", "$", "%", "^", "|", "&", "*", "_", "-", "=", "+", "-", "/", "(", ")", "?", "{", "}", "[", "]", "~", ">", "<", "." ]
|
|
||||||
|
|
||||||
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(password):
|
|
||||||
copy(password)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
soglasie=["yes","y","д","да"]
|
soglasie=["yes","y","д","да"]
|
||||||
nigative=["no","n","н","нет"]
|
nigative=["no","n","н","нет"]
|
||||||
lineal=int(input("Длина пароля: "))
|
lineal=int(input("Длина пароля: "))
|
||||||
@ -38,6 +11,7 @@ if __name__ == "__main__":
|
|||||||
letterS=input("Использовать маленькие буквы? [Д/н] ")
|
letterS=input("Использовать маленькие буквы? [Д/н] ")
|
||||||
spec=input("Использовать спец символы? [Д/н] ")
|
spec=input("Использовать спец символы? [Д/н] ")
|
||||||
variables=[number.lower(),letterB.lower(),letterS.lower(),spec.lower()]
|
variables=[number.lower(),letterB.lower(),letterS.lower(),spec.lower()]
|
||||||
|
|
||||||
for i in range(len(variables)):
|
for i in range(len(variables)):
|
||||||
if variables[i] in soglasie:
|
if variables[i] in soglasie:
|
||||||
variables[i]=True
|
variables[i]=True
|
||||||
@ -51,7 +25,7 @@ if __name__ == "__main__":
|
|||||||
entropy_data=str(entropy)+" bits, "+state
|
entropy_data=str(entropy)+" bits, "+state
|
||||||
print(entropy_data)
|
print(entropy_data)
|
||||||
if(input("Скопировать в буфер обмена? [Д/н] ").lower() in soglasie) :
|
if(input("Скопировать в буфер обмена? [Д/н] ").lower() in soglasie) :
|
||||||
pass_copy(password)
|
copy(password)
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
if(input("Создать QR код? [Д/н] ").lower() in soglasie) :
|
if(input("Создать QR код? [Д/н] ").lower() in soglasie) :
|
||||||
|
|||||||
144
PassgenGUI.py
144
PassgenGUI.py
@ -1,8 +1,24 @@
|
|||||||
from customtkinter import CTk,CTkLabel,CTkButton,CTkEntry,CTkCheckBox
|
from customtkinter import CTk,CTkLabel,CTkButton,CTkEntry,CTkCheckBox,CTkTabview
|
||||||
from PassgenCLI import *
|
from logics.generate import alph_generate,pass_generate
|
||||||
from tkinter import IntVar,END,PhotoImage
|
from tkinter import IntVar,END,PhotoImage
|
||||||
from logics.qr import generate_qr
|
from logics.qr import generate_qr
|
||||||
import os
|
import os
|
||||||
|
window=CTk()
|
||||||
|
window.title("Passgen by anqude")
|
||||||
|
scriptdir=os.path.abspath(__file__)
|
||||||
|
os.chdir(scriptdir.removesuffix('/PassgenGUI.py'))
|
||||||
|
window.tk.call('wm', 'iconphoto', window._w, PhotoImage(file='./ui/icon.png'))
|
||||||
|
|
||||||
|
tabview = CTkTabview(window)
|
||||||
|
tabview.pack(fill="both", expand=True,anchor='center')
|
||||||
|
|
||||||
|
window.geometry("350x220")
|
||||||
|
window.resizable(width=False, height=False)
|
||||||
|
tabview.add("Line") # add tab at the end
|
||||||
|
tabview.add("Graph") # add tab at the end
|
||||||
|
tabview.set("Line") # set currently visible tab
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
counter=8
|
counter=8
|
||||||
|
|
||||||
@ -11,41 +27,31 @@ def Checkvariables():
|
|||||||
return password_lst
|
return password_lst
|
||||||
|
|
||||||
|
|
||||||
window = CTk()
|
|
||||||
window.geometry("350x180")
|
|
||||||
window.title("Passgen by anqude")
|
|
||||||
|
|
||||||
scriptdir=os.path.abspath(__file__)
|
|
||||||
os.chdir(scriptdir.removesuffix('/PassgenGUI.py'))
|
|
||||||
window.tk.call('wm', 'iconphoto', window._w, PhotoImage(file='./ui/icon.png'))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
label = CTkLabel (window,text="Passgen")
|
entry=CTkEntry(tabview.tab("Line"),width = 320)
|
||||||
label.pack()
|
entry.place(x=14, y=15)
|
||||||
|
|
||||||
entry=CTkEntry(window,width = 320)
|
|
||||||
entry.place(x=14, y=35)
|
|
||||||
|
|
||||||
|
|
||||||
Chspec = IntVar()
|
Chspec = IntVar()
|
||||||
CheckCpec = CTkCheckBox(window,text='@~#',variable=Chspec, onvalue=True, offvalue=False)
|
CheckCpec = CTkCheckBox(tabview.tab("Line"),text='@~#',variable=Chspec, onvalue=True, offvalue=False)
|
||||||
CheckCpec.place(x=14, y=70)
|
CheckCpec.place(x=14, y=60)
|
||||||
|
|
||||||
ChletterB = IntVar()
|
ChletterB = IntVar()
|
||||||
CheckLetterB = CTkCheckBox(window,text='A-Z',variable=ChletterB, onvalue=True, offvalue=False)
|
CheckLetterB = CTkCheckBox(tabview.tab("Line"),text='A-Z',variable=ChletterB, onvalue=True, offvalue=False)
|
||||||
CheckLetterB.place(x=94, y=70)
|
CheckLetterB.place(x=94, y=60)
|
||||||
|
|
||||||
ChletterS = IntVar()
|
ChletterS = IntVar()
|
||||||
CheckLetterS = CTkCheckBox(window,text='a-z',variable=ChletterS, onvalue=True, offvalue=False)
|
CheckLetterS = CTkCheckBox(tabview.tab("Line"),text='a-z',variable=ChletterS, onvalue=True, offvalue=False)
|
||||||
CheckLetterS.place(x=174, y=70)
|
CheckLetterS.place(x=174, y=60)
|
||||||
|
|
||||||
Chnumber = IntVar()
|
Chnumber = IntVar()
|
||||||
CheckNumber = CTkCheckBox(window,text='0-9',variable=Chnumber, onvalue=True, offvalue=False)
|
CheckNumber = CTkCheckBox(tabview.tab("Line"),text='0-9',variable=Chnumber, onvalue=True, offvalue=False)
|
||||||
CheckNumber.select()
|
CheckNumber.select()
|
||||||
CheckNumber.place(x=254, y=70)
|
CheckNumber.place(x=254, y=60)
|
||||||
|
|
||||||
def minus_click():
|
def minus_click():
|
||||||
counter=int(label2.get())
|
counter=int(label2.get())
|
||||||
@ -55,11 +61,11 @@ def minus_click():
|
|||||||
counter-=1
|
counter-=1
|
||||||
label2.delete(0, END)
|
label2.delete(0, END)
|
||||||
label2.insert(0, counter)
|
label2.insert(0, counter)
|
||||||
minus = CTkButton(window,text="-",command=minus_click,width = 27)
|
minus = CTkButton(tabview.tab("Line"),text="-",command=minus_click,width = 27)
|
||||||
minus.place(x=12, y=100)
|
minus.place(x=12, y=100)
|
||||||
|
|
||||||
|
|
||||||
label2=CTkEntry(window,width = 40)
|
label2=CTkEntry(tabview.tab("Line"),width = 40)
|
||||||
label2.insert(0, counter)
|
label2.insert(0, counter)
|
||||||
label2.place(x=47, y=100)
|
label2.place(x=47, y=100)
|
||||||
|
|
||||||
@ -69,7 +75,7 @@ def plus_click():
|
|||||||
counter+=1
|
counter+=1
|
||||||
label2.delete(0, END)
|
label2.delete(0, END)
|
||||||
label2.insert(0, counter)
|
label2.insert(0, counter)
|
||||||
plus = CTkButton(window,text="+",command=plus_click,width = 27)
|
plus = CTkButton(tabview.tab("Line"),text="+",command=plus_click,width = 27)
|
||||||
plus.place(x=95, y=100)
|
plus.place(x=95, y=100)
|
||||||
|
|
||||||
|
|
||||||
@ -80,29 +86,29 @@ def handle_click():
|
|||||||
entry.insert(0, password)
|
entry.insert(0, password)
|
||||||
except:
|
except:
|
||||||
entry.insert(0, "")
|
entry.insert(0, "")
|
||||||
button=CTkButton(window,text="Generate pass!", command=handle_click,width = 39)
|
button=CTkButton(tabview.tab("Line"),text="Generate pass!", command=handle_click,width = 39)
|
||||||
button.place(x=12, y=140)
|
button.place(x=12, y=140)
|
||||||
|
|
||||||
|
|
||||||
def copy_click():
|
def copy_click():
|
||||||
name = entry.get()
|
from pyperclip import copy
|
||||||
pass_copy(name)
|
copy(entry.get())
|
||||||
Copy = CTkButton(window,text="Copy!",command=copy_click, width = 39)
|
Copy = CTkButton(tabview.tab("Line"),text="Copy!",command=copy_click, width = 39)
|
||||||
Copy.place(x=122, y=140)
|
Copy.place(x=122, y=140)
|
||||||
|
|
||||||
|
|
||||||
def genadiy():
|
def genadiy():
|
||||||
generate_qr(entry.get())
|
generate_qr(entry.get())
|
||||||
from tkinter import Toplevel,Canvas
|
from tkinter import Toplevel,Label
|
||||||
from PIL import ImageTk, Image
|
from PIL import ImageTk, Image
|
||||||
window = Toplevel()
|
window = Toplevel()
|
||||||
window.geometry("150x150")
|
window.geometry("200x200")
|
||||||
window.configure(bg="black")
|
window.configure(bg="#242424")
|
||||||
window.title("QR")
|
window.title("QR")
|
||||||
window.tk.call('wm', 'iconphoto', window._w, PhotoImage(file='qr.png'))
|
window.tk.call('wm', 'iconphoto', window._w, PhotoImage(file='qr.png'))
|
||||||
bg = ImageTk.PhotoImage(file="qr.png")
|
bg = ImageTk.PhotoImage(file="qr.png")
|
||||||
canvas = Canvas(window,background="black",highlightbackground="black")
|
label = Label(window,background="#242424",highlightbackground="#242424")
|
||||||
canvas.pack(fill="both", expand=True,anchor='center')
|
label.pack(fill="both", expand=True,anchor='center')
|
||||||
|
|
||||||
def resize_image(win):
|
def resize_image(win):
|
||||||
image = Image.open("qr.png")
|
image = Image.open("qr.png")
|
||||||
@ -113,20 +119,74 @@ def genadiy():
|
|||||||
else:
|
else:
|
||||||
high=wide
|
high=wide
|
||||||
resized = image.resize((wide, high))
|
resized = image.resize((wide, high))
|
||||||
canvas.delete("all")
|
|
||||||
image2 = ImageTk.PhotoImage(resized)
|
image2 = ImageTk.PhotoImage(resized)
|
||||||
window.image2=image2
|
window.image2=image2
|
||||||
canvas.create_image(0, 0, image=image2, anchor='nw')
|
label.configure(image=image2)
|
||||||
|
|
||||||
window.bind("<Configure>", resize_image)
|
window.bind("<Configure>", resize_image)
|
||||||
window.mainloop()
|
window.mainloop()
|
||||||
|
|
||||||
|
genqr = CTkButton(tabview.tab("Line"),text="Generate QR!",command=genadiy,width = 39)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
genqr = CTkButton(window,text="Generate QR!",command=genadiy,width = 39)
|
|
||||||
genqr.place(x=175, y=140)
|
genqr.place(x=175, y=140)
|
||||||
|
|
||||||
|
from logics.graph import ggraph,anonim
|
||||||
|
|
||||||
|
label1=CTkLabel(tabview.tab("Graph"),text="X",)
|
||||||
|
label1.place(x=60, y=15)
|
||||||
|
|
||||||
|
|
||||||
|
x_entry=CTkEntry(tabview.tab("Graph"),width=100)
|
||||||
|
x_entry.place(x=14, y=45)
|
||||||
|
|
||||||
|
Label3=CTkLabel(tabview.tab("Graph"),text="Y",)
|
||||||
|
Label3.place(x=170, y=15)
|
||||||
|
|
||||||
|
y_entry=CTkEntry(tabview.tab("Graph"),width=100)
|
||||||
|
y_entry.place(x=125, y=45)
|
||||||
|
|
||||||
|
label3=CTkLabel(tabview.tab("Graph"),text="Length")
|
||||||
|
label3.place(x=265, y=15)
|
||||||
|
|
||||||
|
len_entry=CTkEntry(tabview.tab("Graph"),width=100)
|
||||||
|
len_entry.place(x=235, y=45)
|
||||||
|
|
||||||
|
x_entry.insert(0, 3)
|
||||||
|
y_entry.insert(0,3)
|
||||||
|
len_entry.insert(0,4)
|
||||||
|
|
||||||
|
def gena():
|
||||||
|
n=int(len_entry.get())
|
||||||
|
yn=int(y_entry.get())
|
||||||
|
xn=int(x_entry.get())
|
||||||
|
from tkinter import Canvas, Toplevel
|
||||||
|
root = Toplevel()
|
||||||
|
root.configure(background="#242424")
|
||||||
|
root.title("Graph")
|
||||||
|
root.geometry("400x400")
|
||||||
|
resx,resy=400,400
|
||||||
|
canvas = Canvas(root,background="#242424",highlightbackground="#242424")
|
||||||
|
canvas.pack(fill="both", expand=True)
|
||||||
|
a=ggraph(n, xn, yn)
|
||||||
|
Xcoordinates,Ycoordinates,Xnull_coordinates,Ynull_coordinates=anonim(n,xn,yn,a,resx,resy)
|
||||||
|
def draw(n,xn,yn,Xcoordinates,Ycoordinates,Xnull_coordinates,Ynull_coordinates):
|
||||||
|
for i in range (xn): #кол-во линий
|
||||||
|
for j in range(yn): #кол-во строк
|
||||||
|
canvas.create_oval(Xnull_coordinates[i]-3,Ynull_coordinates[j]-3,Xnull_coordinates[i]+3,Ynull_coordinates[j]+3,width=7,fill="white",outline="#565b5e")
|
||||||
|
|
||||||
|
for i in range (n-1): #Кол-во точек -1 тк это линии лол
|
||||||
|
canvas.create_line(Xcoordinates[i], Ycoordinates[i], Xcoordinates[i+1], Ycoordinates[i+1],width=7,arrow="last",fill="white")
|
||||||
|
draw(n,xn,yn,Xcoordinates,Ycoordinates,Xnull_coordinates,Ynull_coordinates)
|
||||||
|
def sizable(event):
|
||||||
|
resx,resy = event.width, event.height
|
||||||
|
canvas.delete("all")
|
||||||
|
Xcoordinates,Ycoordinates,Xnull_coordinates,Ynull_coordinates=anonim(n,xn,yn,a,resx,resy)
|
||||||
|
draw(n, xn, yn,Xcoordinates,Ycoordinates,Xnull_coordinates,Ynull_coordinates)
|
||||||
|
|
||||||
|
canvas.bind('<Configure>', sizable)
|
||||||
|
root.mainloop()
|
||||||
|
|
||||||
|
|
||||||
|
generate_button=CTkButton(tabview.tab("Graph"),command=gena, text="Generate!",width=320)
|
||||||
|
generate_button.place(x=15, y=95)
|
||||||
|
|
||||||
window.mainloop()
|
window.mainloop()
|
||||||
|
|||||||
24
logics/generate.py
Normal file
24
logics/generate.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
from secrets import choice # Для безопасной генерации пароля
|
||||||
|
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=[ "!", "@", "№", "#", "$", "%", "^", "|", "&", "*", "_", "-", "=", "+", "-", "/", "(", ")", "?", "{", "}", "[", "]", "~", ">", "<", "." ]
|
||||||
|
|
||||||
|
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
|
||||||
@ -72,4 +72,3 @@ def anonim(n,xn,yn,a,resx,resy):
|
|||||||
Ynull_coordinates.append(Ynull_coordinate)
|
Ynull_coordinates.append(Ynull_coordinate)
|
||||||
|
|
||||||
return(Xcoordinates,Ycoordinates,Xnull_coordinates,Ynull_coordinates)
|
return(Xcoordinates,Ycoordinates,Xnull_coordinates,Ynull_coordinates)
|
||||||
print(len(ggraph(4, 4, 3)))
|
|
||||||
@ -3,11 +3,10 @@ def generate_qr(password):
|
|||||||
qr = qrcode.QRCode()
|
qr = qrcode.QRCode()
|
||||||
qr.add_data('password: '+password)
|
qr.add_data('password: '+password)
|
||||||
qr.make(fit=True)
|
qr.make(fit=True)
|
||||||
img = qr.make_image(fill_color="white", back_color="black")
|
img = qr.make_image(fill_color="white", back_color="#242424")
|
||||||
img.save("qr.png")
|
img.save("qr.png")
|
||||||
|
|
||||||
def generate_qr_text(password):
|
def generate_qr_text(password):
|
||||||
import qrcode
|
|
||||||
qr = qrcode.QRCode()
|
qr = qrcode.QRCode()
|
||||||
qr.add_data('password: '+password)
|
qr.add_data('password: '+password)
|
||||||
return(qr.print_ascii())
|
return(qr.print_ascii())
|
||||||
Loading…
x
Reference in New Issue
Block a user