Add files via upload
This commit is contained in:
parent
766f0a4856
commit
2f6e69c635
58
Passgen.py
Normal file
58
Passgen.py
Normal file
@ -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)
|
||||||
101
front.py
Normal file
101
front.py
Normal file
@ -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("<Button-1>", handle_click)
|
||||||
|
genqr.bind("<Button-1>", 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("<Button-1>", plus_click)
|
||||||
|
minus = ttk.Button(text="-")
|
||||||
|
minus.bind("<Button-1>", minus_click)
|
||||||
|
Copy = ttk.Button(text="Copy!",width = 39)
|
||||||
|
Copy.bind("<Button-1>", 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()
|
||||||
7
qr.py
Normal file
7
qr.py
Normal file
@ -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")
|
||||||
15
qrview.py
Normal file
15
qrview.py
Normal file
@ -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()
|
||||||
Loading…
x
Reference in New Issue
Block a user