Add files via upload
This commit is contained in:
parent
5c8759b233
commit
1316747313
82
GraphShow.py
Normal file
82
GraphShow.py
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
from customtkinter import CTk,CTkLabel,CTkButton,CTkEntry
|
||||||
|
from tkinter import PhotoImage
|
||||||
|
import os
|
||||||
|
from logics.graph import ggraph,anonim
|
||||||
|
|
||||||
|
|
||||||
|
scriptdir=os.path.abspath(__file__)
|
||||||
|
os.chdir(scriptdir.removesuffix('/GraphShow.py'))
|
||||||
|
|
||||||
|
window = CTk()
|
||||||
|
window.geometry("530x180")
|
||||||
|
|
||||||
|
window.title("Passgen by anqude")
|
||||||
|
window.tk.call('wm', 'iconphoto', window._w, PhotoImage(file='./ui/icon.png'))
|
||||||
|
|
||||||
|
|
||||||
|
label1=CTkLabel(text="X",master=window)
|
||||||
|
label1.grid(row=0, column=0, padx=20, pady=10)
|
||||||
|
|
||||||
|
|
||||||
|
x_entry=CTkEntry(master=window)
|
||||||
|
x_entry.grid(row=1, column=0, padx=20, pady=10)
|
||||||
|
|
||||||
|
|
||||||
|
label2=CTkLabel(text="Y",master=window)
|
||||||
|
label2.grid(row=0, column=1, padx=20, pady=10)
|
||||||
|
|
||||||
|
y_entry=CTkEntry(master=window)
|
||||||
|
y_entry.grid(row=1, column=1, padx=20, pady=10)
|
||||||
|
|
||||||
|
|
||||||
|
label3=CTkLabel(text="Length",master=window)
|
||||||
|
label3.grid(row=0, column=2, padx=20, pady=10)
|
||||||
|
|
||||||
|
len_entry=CTkEntry(master=window)
|
||||||
|
len_entry.grid(row=1, column=2, padx=20, pady=10)
|
||||||
|
|
||||||
|
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())
|
||||||
|
graphs=ggraph(n,xn,yn)
|
||||||
|
graph2=""
|
||||||
|
for i in range(len(graphs)):
|
||||||
|
graph2+=str(graphs[i]).replace("[0"," · ").replace("]","").replace("[","").replace("[0"," · ").replace(", 0"," · ").replace(",","")+"\n"
|
||||||
|
from tkinter import Canvas, Toplevel
|
||||||
|
root = Toplevel()
|
||||||
|
root.configure(background="#242424")
|
||||||
|
root.geometry("400x400")
|
||||||
|
canvas = Canvas(root,background="#242424",highlightbackground="#242424")
|
||||||
|
canvas.pack(fill="both", expand=True)
|
||||||
|
root.update_idletasks()
|
||||||
|
resx,resy = root.winfo_width(),root.winfo_height()
|
||||||
|
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(command=gena, text="generate",master=window)
|
||||||
|
generate_button.grid( row=2, column=0, padx=20, pady=10)
|
||||||
|
|
||||||
|
|
||||||
|
window.mainloop()
|
||||||
@ -1,6 +1,7 @@
|
|||||||
from secrets import choice # Для безопасной генерации пароля
|
from secrets import choice # Для безопасной генерации пароля
|
||||||
from pyperclip import copy# Для копирования в буфер обмена
|
from pyperclip import copy# Для копирования в буфер обмена
|
||||||
|
from logics.entropy import get_entopy
|
||||||
|
from logics.qr import generate_qr_text
|
||||||
numbers=['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
|
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', ]
|
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"]
|
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"]
|
||||||
@ -25,8 +26,7 @@ def pass_generate(password_lst,lineal):
|
|||||||
password=''.join(password)
|
password=''.join(password)
|
||||||
return password
|
return password
|
||||||
|
|
||||||
def pass_copy(copys,password):
|
def pass_copy(password):
|
||||||
if copys==True:
|
|
||||||
copy(password)
|
copy(password)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@ -47,8 +47,15 @@ if __name__ == "__main__":
|
|||||||
password_lst=alph_generate(number,letterB,letterS,spec)
|
password_lst=alph_generate(number,letterB,letterS,spec)
|
||||||
password=pass_generate(password_lst,lineal)
|
password=pass_generate(password_lst,lineal)
|
||||||
print(password)
|
print(password)
|
||||||
|
entropy,state=get_entopy(password)
|
||||||
|
entropy_data=str(entropy)+" bits, "+state
|
||||||
|
print(entropy_data)
|
||||||
if(input("Скопировать в буфер обмена? [Д/н] ").lower() in soglasie) :
|
if(input("Скопировать в буфер обмена? [Д/н] ").lower() in soglasie) :
|
||||||
copys=True
|
pass_copy(password)
|
||||||
else:
|
else:
|
||||||
copys=False
|
pass
|
||||||
pass_copy(copys,password)
|
if(input("Создать QR код? [Д/н] ").lower() in soglasie) :
|
||||||
|
generate_qr_text(password)
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
132
PassgenGUI.py
Normal file
132
PassgenGUI.py
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
from customtkinter import CTk,CTkLabel,CTkButton,CTkEntry,CTkCheckBox
|
||||||
|
from PassgenCLI import *
|
||||||
|
from tkinter import IntVar,END,PhotoImage
|
||||||
|
from logics.qr import generate_qr
|
||||||
|
import os
|
||||||
|
|
||||||
|
counter=8
|
||||||
|
|
||||||
|
def Checkvariables():
|
||||||
|
password_lst=alph_generate(Chnumber.get(),ChletterB.get(),ChletterS.get(),Chspec.get())
|
||||||
|
return password_lst
|
||||||
|
|
||||||
|
|
||||||
|
window = CTk()
|
||||||
|
window.geometry("350x180")
|
||||||
|
window.title("Passgen by anqude")
|
||||||
|
|
||||||
|
scriptdir=os.path.abspath(__file__)
|
||||||
|
os.chdir(scriptdir.removesuffix('/PassgenerGUI.py'))
|
||||||
|
window.tk.call('wm', 'iconphoto', window._w, PhotoImage(file='./ui/icon.png'))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
label = CTkLabel (window,text="Passgen")
|
||||||
|
label.pack()
|
||||||
|
|
||||||
|
entry=CTkEntry(window,width = 320)
|
||||||
|
entry.place(x=14, y=35)
|
||||||
|
|
||||||
|
|
||||||
|
Chspec = IntVar()
|
||||||
|
CheckCpec = CTkCheckBox(window,text='@~#',variable=Chspec, onvalue=True, offvalue=False)
|
||||||
|
CheckCpec.place(x=14, y=70)
|
||||||
|
|
||||||
|
ChletterB = IntVar()
|
||||||
|
CheckLetterB = CTkCheckBox(window,text='A-Z',variable=ChletterB, onvalue=True, offvalue=False)
|
||||||
|
CheckLetterB.place(x=94, y=70)
|
||||||
|
|
||||||
|
ChletterS = IntVar()
|
||||||
|
CheckLetterS = CTkCheckBox(window,text='a-z',variable=ChletterS, onvalue=True, offvalue=False)
|
||||||
|
CheckLetterS.place(x=174, y=70)
|
||||||
|
|
||||||
|
Chnumber = IntVar()
|
||||||
|
CheckNumber = CTkCheckBox(window,text='0-9',variable=Chnumber, onvalue=True, offvalue=False)
|
||||||
|
CheckNumber.select()
|
||||||
|
CheckNumber.place(x=254, y=70)
|
||||||
|
|
||||||
|
def minus_click():
|
||||||
|
counter=int(label2.get())
|
||||||
|
if counter==1:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
counter-=1
|
||||||
|
label2.delete(0, END)
|
||||||
|
label2.insert(0, counter)
|
||||||
|
minus = CTkButton(window,text="-",command=minus_click,width = 27)
|
||||||
|
minus.place(x=12, y=100)
|
||||||
|
|
||||||
|
|
||||||
|
label2=CTkEntry(window,width = 40)
|
||||||
|
label2.insert(0, counter)
|
||||||
|
label2.place(x=47, y=100)
|
||||||
|
|
||||||
|
|
||||||
|
def plus_click():
|
||||||
|
counter=int(label2.get())
|
||||||
|
counter+=1
|
||||||
|
label2.delete(0, END)
|
||||||
|
label2.insert(0, counter)
|
||||||
|
plus = CTkButton(window,text="+",command=plus_click,width = 27)
|
||||||
|
plus.place(x=95, y=100)
|
||||||
|
|
||||||
|
|
||||||
|
def handle_click():
|
||||||
|
entry.delete(0, END)
|
||||||
|
try:
|
||||||
|
password=pass_generate(Checkvariables(),int(label2.get()))
|
||||||
|
entry.insert(0, password)
|
||||||
|
except:
|
||||||
|
entry.insert(0, "")
|
||||||
|
button=CTkButton(window,text="Generate pass!", command=handle_click,width = 39)
|
||||||
|
button.place(x=12, y=140)
|
||||||
|
|
||||||
|
|
||||||
|
def copy_click():
|
||||||
|
name = entry.get()
|
||||||
|
pass_copy(name)
|
||||||
|
Copy = CTkButton(window,text="Copy!",command=copy_click, width = 39)
|
||||||
|
Copy.place(x=122, y=140)
|
||||||
|
|
||||||
|
|
||||||
|
def genadiy():
|
||||||
|
generate_qr(entry.get())
|
||||||
|
from tkinter import Toplevel,Canvas
|
||||||
|
from PIL import ImageTk, Image
|
||||||
|
window = Toplevel()
|
||||||
|
window.geometry("150x150")
|
||||||
|
window.configure(bg="black")
|
||||||
|
window.title("QR")
|
||||||
|
window.tk.call('wm', 'iconphoto', window._w, PhotoImage(file='qr.png'))
|
||||||
|
bg = ImageTk.PhotoImage(file="qr.png")
|
||||||
|
canvas = Canvas(window,background="black",highlightbackground="black")
|
||||||
|
canvas.pack(fill="both", expand=True,anchor='center')
|
||||||
|
|
||||||
|
def resize_image(win):
|
||||||
|
image = Image.open("qr.png")
|
||||||
|
wide=win.width
|
||||||
|
high=win.height
|
||||||
|
if high < wide:
|
||||||
|
wide=high
|
||||||
|
else:
|
||||||
|
high=wide
|
||||||
|
resized = image.resize((wide, high))
|
||||||
|
canvas.delete("all")
|
||||||
|
image2 = ImageTk.PhotoImage(resized)
|
||||||
|
window.image2=image2
|
||||||
|
canvas.create_image(0, 0, image=image2, anchor='nw')
|
||||||
|
|
||||||
|
window.bind("<Configure>", resize_image)
|
||||||
|
window.mainloop()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
genqr = CTkButton(window,text="Generate QR!",command=genadiy,width = 39)
|
||||||
|
genqr.place(x=175, y=140)
|
||||||
|
|
||||||
|
window.mainloop()
|
||||||
13
logics/entropy.py
Normal file
13
logics/entropy.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
from password_strength import PasswordStats
|
||||||
|
|
||||||
|
def get_entopy(password):
|
||||||
|
stats=PasswordStats(password)
|
||||||
|
if(stats.entropy_bits<45):
|
||||||
|
state="weak"
|
||||||
|
elif(stats.entropy_bits<80):
|
||||||
|
state="medium"
|
||||||
|
elif(stats.entropy_bits<=110):
|
||||||
|
state="strong"
|
||||||
|
else:
|
||||||
|
state="very strong"
|
||||||
|
return int(stats.entropy_bits),state
|
||||||
75
logics/graph.py
Normal file
75
logics/graph.py
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
import random
|
||||||
|
import numpy
|
||||||
|
def graph(x,y): #Создаём двумерный массив, заполненный гулями
|
||||||
|
a = []
|
||||||
|
for i in range(y):
|
||||||
|
a.append([])
|
||||||
|
for j in range(x):
|
||||||
|
a[i].append(0)
|
||||||
|
return a
|
||||||
|
|
||||||
|
def ggraph(n,xn,yn):
|
||||||
|
m = 1
|
||||||
|
xym = [xn,yn]
|
||||||
|
b = graph(xn, yn)
|
||||||
|
av = [[-1,-1]]
|
||||||
|
try:
|
||||||
|
masx = [i for i in range(2,xn)]
|
||||||
|
masy = [i for i in range(2,yn)]
|
||||||
|
except:
|
||||||
|
masx = [1]
|
||||||
|
masy = [1]
|
||||||
|
while m < n+1:
|
||||||
|
x = random.randint(0, xn-1)
|
||||||
|
y = random.randint(0, yn-1)
|
||||||
|
x0 = av[len(av)-1][0]
|
||||||
|
y0 = av[len(av)-1][1]
|
||||||
|
a = [x0,y0,x,y]
|
||||||
|
if (b[y][x] == 0) and (((abs(a[0]-a[2])==1 and (abs(a[1]-a[3]) in masy) ) or (abs(a[1]-a[3])==1 and abs(a[0]-a[2]) in masx)) or ((a[0] == a[2] or a[0]+1 == a[2] or a[0]-1 == a[2]) and (a[1] == a[3] or a[1]+1 == a[3] or a[1]-1 == a[3])) )or (x0==-1 and y0==-1):
|
||||||
|
b[y][x] = m
|
||||||
|
av.append([x,y])
|
||||||
|
m += 1
|
||||||
|
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
return b
|
||||||
|
|
||||||
|
|
||||||
|
def find(matrix, value):
|
||||||
|
value_indexs = [ ( matrix.index(row), row.index(value) ) for row in matrix if value in row]
|
||||||
|
return value_indexs
|
||||||
|
def anonim(n,xn,yn,a,resx,resy):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Xcoordinates=[]
|
||||||
|
Ycoordinates=[]
|
||||||
|
Xnull_coordinates=[]
|
||||||
|
Ynull_coordinates=[]
|
||||||
|
|
||||||
|
for i in range(1,n+1):
|
||||||
|
f=find(a, i)
|
||||||
|
if f!=[]:
|
||||||
|
index=f[0]
|
||||||
|
indeY=index[0]
|
||||||
|
indeX=index[1]
|
||||||
|
Xcoordinate=int(resx/(xn+1)*(indeX+1))
|
||||||
|
Ycoordinate=int(resy/(yn+1)*(indeY+1))
|
||||||
|
Xcoordinates.append(Xcoordinate)
|
||||||
|
Ycoordinates.append(Ycoordinate)
|
||||||
|
|
||||||
|
ups=[]
|
||||||
|
for k in range(xn):
|
||||||
|
Xnull_coordinate=int(resx/(xn+1)*(k+1))
|
||||||
|
ups.append(Xnull_coordinate)
|
||||||
|
for u in range(yn):
|
||||||
|
Xnull_coordinates+=ups
|
||||||
|
for u in range(yn):
|
||||||
|
Ynull_coordinate=int(resy/(yn+1)*(u+1))
|
||||||
|
Ynull_coordinates.append(Ynull_coordinate)
|
||||||
|
|
||||||
|
return(Xcoordinates,Ycoordinates,Xnull_coordinates,Ynull_coordinates)
|
||||||
|
print(len(ggraph(4, 4, 3)))
|
||||||
13
logics/qr.py
Normal file
13
logics/qr.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
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")
|
||||||
|
|
||||||
|
def generate_qr_text(password):
|
||||||
|
import qrcode
|
||||||
|
qr = qrcode.QRCode()
|
||||||
|
qr.add_data('password: '+password)
|
||||||
|
return(qr.print_ascii())
|
||||||
Loading…
x
Reference in New Issue
Block a user