Add files via upload

This commit is contained in:
anqude 2023-01-08 21:56:33 +04:00 committed by GitHub
parent a2b7cfe401
commit b42605e807
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 228 additions and 38 deletions

65
GraphShow.py Normal file
View File

@ -0,0 +1,65 @@
from customtkinter import CTk,CTkLabel,CTkButton,CTkEntry,BOTH,X,Y
from tkinter import PhotoImage
import os
from save import write_db
from graph import ggraph
graphs=""
def save_pass():
login=login_entry.get()
Password=Password_entry.get()
if Password!="" and login!="":
write_db(login,Password)
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)
def gena():
n=int(len_entry.get())
yn=int(y_entry.get())
xn=int(x_entry.get())
global graphs
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 customtkinter import CTkToplevel
window = CTkToplevel()
label=CTkLabel(text=graph2,master=window)
label.grid( row=0, column=0)
generate_button=CTkButton(command=gena, text="generate",master=window)
generate_button.grid( row=2, column=0, padx=20, pady=10)
window.mainloop()

View File

@ -51,4 +51,4 @@ if __name__ == "__main__":
copys=True copys=True
else: else:
copys=False copys=False
pass_copy(copys,password) pass_copy(copys,password)

View File

@ -1,4 +1,4 @@
from customtkinter import CTk,CTkLabel,CTkButton,CTkEntry,CTkCheckBox,CTkToplevel from customtkinter import CTk,CTkLabel,CTkButton,CTkEntry,CTkCheckBox,CTkToplevel,CTkImage
from PassgenCLI import * from PassgenCLI import *
from tkinter import IntVar,END,PhotoImage from tkinter import IntVar,END,PhotoImage
from qr import generate_qr from qr import generate_qr
@ -11,38 +11,39 @@ def Checkvariables():
return password_lst return password_lst
scriptdir=os.path.abspath(__file__)
os.chdir(scriptdir.removesuffix('/PassgenerGUI.py'))
window = CTk() window = CTk()
window.geometry("350x180") window.geometry("350x180")
window.resizable(width=False, height=False) window.title("Passgen by anqude")
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')) window.tk.call('wm', 'iconphoto', window._w, PhotoImage(file='./ui/icon.png'))
label = CTkLabel(text="Passgen")
label = CTkLabel (window,text="Passgen")
label.pack() label.pack()
entry=CTkEntry(window,width = 320)
entry=CTkEntry(width = 320)
entry.place(x=14, y=35) entry.place(x=14, y=35)
Chspec = IntVar() Chspec = IntVar()
CheckCpec = CTkCheckBox(text='@~#',variable=Chspec, onvalue=True, offvalue=False) CheckCpec = CTkCheckBox(window,text='@~#',variable=Chspec, onvalue=True, offvalue=False)
CheckCpec.place(x=14, y=70) CheckCpec.place(x=14, y=70)
ChletterB = IntVar() ChletterB = IntVar()
CheckLetterB = CTkCheckBox(text='A-Z',variable=ChletterB, onvalue=True, offvalue=False) CheckLetterB = CTkCheckBox(window,text='A-Z',variable=ChletterB, onvalue=True, offvalue=False)
CheckLetterB.place(x=94, y=70) CheckLetterB.place(x=94, y=70)
ChletterS = IntVar() ChletterS = IntVar()
CheckLetterS = CTkCheckBox(text='a-z',variable=ChletterS, onvalue=True, offvalue=False) CheckLetterS = CTkCheckBox(window,text='a-z',variable=ChletterS, onvalue=True, offvalue=False)
CheckLetterS.place(x=174, y=70) CheckLetterS.place(x=174, y=70)
Chnumber = IntVar() Chnumber = IntVar()
CheckNumber = CTkCheckBox(text='0-9',variable=Chnumber, onvalue=True, offvalue=False) CheckNumber = CTkCheckBox(window,text='0-9',variable=Chnumber, onvalue=True, offvalue=False)
CheckNumber.select() CheckNumber.select()
CheckNumber.place(x=254, y=70) CheckNumber.place(x=254, y=70)
@ -55,11 +56,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(text="-",command=minus_click,width = 27) minus = CTkButton(window,text="-",command=minus_click,width = 27)
minus.place(x=12, y=100) minus.place(x=12, y=100)
label2=CTkEntry(width = 40) label2=CTkEntry(window,width = 40)
label2.insert(0, counter) label2.insert(0, counter)
label2.place(x=47, y=100) label2.place(x=47, y=100)
@ -70,7 +71,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(text="+",command=plus_click,width = 27) plus = CTkButton(window,text="+",command=plus_click,width = 27)
plus.place(x=95, y=100) plus.place(x=95, y=100)
@ -81,33 +82,46 @@ def handle_click():
entry.insert(0, password) entry.insert(0, password)
except: except:
entry.insert(0, "") entry.insert(0, "")
button=CTkButton(text="Generate pass!", command=handle_click,width = 39) button=CTkButton(window,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() name = entry.get()
pass_copy(True,name) pass_copy(True,name)
Copy = CTkButton(text="Copy!",command=copy_click, width = 39) Copy = CTkButton(window,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 PIL import ImageTk,Image from tkinter import Toplevel,Canvas
window = CTkToplevel() from PIL import ImageTk, Image
window.configure(background="black") window = Toplevel()
window.geometry("150x150")
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'))
window.geometry("150x150") bg = ImageTk.PhotoImage(file="qr.png")
window.resizable(width=False, height=False) canvas = Canvas(window)
window.update_idletasks() canvas.pack(fill="both", expand=True)
width=window.winfo_width() canvas.create_image(0,0,image=bg, anchor='nw')
height=window.winfo_height()
img = ImageTk.PhotoImage(Image.open("qr.png").resize((width,height)),master = window) def resize_image(win):
qr=CTkButton(window,text="",image=img,border=0,fg_color=None,hover_color=None,bg_color=None) global image, resized, image2
qr.pack() image = Image.open("qr.png")
genqr = CTkButton(text="Generate QR!",command=genadiy,width = 39) resized = image.resize((win.width, win.height), Image.Resampling.LANCZOS)
image2 = ImageTk.PhotoImage(resized)
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) genqr.place(x=175, y=140)
window.mainloop() window.mainloop()

View File

@ -5,26 +5,26 @@
### Dependencies ### Dependencies
**Python** **Python**
```sh ```sh
pip install tk pyperclip qrcode customtkinter pip install tk pyperclip qrcode password-strength
``` ```
**On debian** **On debian**
```sh ```sh
sudo apt install python3-tk python3-pil.imagetk sudo apt install python3-tk python3-pil.imagetk pytho3-pip python3
``` ```
**On fedora** **On fedora**
```sh ```sh
sudo dnf install python3-tkinter python3-pillow-tk sudo dnf install python3-tkinter python3-pillow-tk python3 python-pip
``` ```
<img src="https://i.imgur.com/f1cBAgi.png" alt="img" align="right" width="200px"> <img src="https://i.imgur.com/KUsAunA.png" alt="img" align="right" width="150px">
<img src="https://i.imgur.com/asgXlG3.png" alt="img" align="right" width="200px"> <img src="https://i.imgur.com/IYXMmxQ.png" alt="img" align="right" width="200px">
<img src="https://i.imgur.com/FvNREK4.png" alt="img" align="right" width="150px">
### Features ### Features
- using cusom passassword - using cusom passassword
- copy passwoed to clipboard - copy passwoed to clipboard
- share password via QR code - share password via QR code
- support dark and light system theme

47
SaveToDB.py Normal file
View File

@ -0,0 +1,47 @@
from customtkinter import CTk,CTkLabel,CTkButton,CTkEntry,BOTH,X,Y
from tkinter import PhotoImage
import os
from save import write_db
def save_pass():
login=login_entry.get()
Password=Password_entry.get()
if Password!="" and login!="":
write_db(login,Password)
scriptdir=os.path.abspath(__file__)
os.chdir(scriptdir.removesuffix('/SaveToDB.py'))
window = CTk()
window.geometry("350x180")
window.title("Passgen by anqude")
window.tk.call('wm', 'iconphoto', window._w, PhotoImage(file='./ui/icon.png'))
label1=CTkLabel(window,text="Login")
label1.pack(fill=BOTH,)
login_entry=CTkEntry(window)
login_entry.pack(fill=BOTH)
label2=CTkLabel(window,text="Password")
label2.pack(fill=BOTH)
Password_entry=CTkEntry(window)
Password_entry.pack(fill=BOTH)
Save_button=CTkButton(window,text="Save!", command=save_pass)
Save_button.pack(fill=BOTH, pady=10)
window.mainloop()

0
db.json Normal file
View File

19
entropy.py Normal file
View File

@ -0,0 +1,19 @@
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
if __name__=="__main__":
password=input()
entropy,state=get_entopy(password)
print(entropy,state)

40
graph.py Normal file
View File

@ -0,0 +1,40 @@
import random
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

5
save.py Normal file
View File

@ -0,0 +1,5 @@
def write_db(login,Password):
import json
strdata = {login:Password}
db_open = open("db.json", "w")
json.dump(strdata,db_open)