just new update
now it's able to import and export, etc
This commit is contained in:
parent
dcd6175041
commit
2717384e8d
@ -1,12 +1,26 @@
|
||||
from customtkinter import CTkLabel,CTkButton,CTkEntry,CTkScrollableFrame,CTkTabview,CTk,get_appearance_mode
|
||||
from logics import *
|
||||
from customtkinter import CTkLabel,CTkButton,CTkEntry,CTkScrollableFrame,CTkTabview,CTk,get_appearance_mode,set_widget_scaling,set_window_scaling
|
||||
from tkinter import PhotoImage
|
||||
import os
|
||||
import sys
|
||||
|
||||
window = CTk()
|
||||
window.title("PassMan by Anqude")
|
||||
scriptdir=os.path.abspath(__file__)
|
||||
os.chdir(scriptdir.removesuffix('/PassmanGUI.py'))
|
||||
window.tk.call('wm', 'iconphoto', window._w, PhotoImage(file='./ui/icon.png'))
|
||||
|
||||
try:
|
||||
direct=scriptdir.removesuffix('\PassmanGUI.py')
|
||||
assert os.path.isdir(direct), 'You fucked bro'
|
||||
|
||||
except:
|
||||
direct=scriptdir.removesuffix('/PassmanGUI.py')
|
||||
|
||||
sys.path.append(direct)
|
||||
|
||||
|
||||
|
||||
from logics import *
|
||||
window.title("PassMan by Anqude")
|
||||
|
||||
|
||||
theme=get_appearance_mode()
|
||||
if theme=="Dark":
|
||||
bg_color="#242424"
|
||||
@ -14,6 +28,10 @@ if theme=="Dark":
|
||||
else:
|
||||
fg_color="#242424"
|
||||
bg_color="#dbdbdb"
|
||||
|
||||
scriptdir=os.path.abspath(__file__)
|
||||
os.chdir(direct)
|
||||
window.tk.call('wm', 'iconphoto', window._w, PhotoImage(file='./ui/icon.png'))
|
||||
tabview = CTkTabview(window)
|
||||
tab_write=tabview.add("Write") # add tab at the end
|
||||
tab_read=tabview.add("Read") # add tab at the end
|
||||
@ -210,4 +228,33 @@ Site_label.grid(row=0, column=0,padx=12,pady=10)
|
||||
Login_label.grid(row=1, column=0,padx=12,pady=10)
|
||||
Password_label.grid(row=2, column=0,padx=12,pady=10)
|
||||
SaveBut.grid(row=3, column=1,padx=12,pady=10)
|
||||
def importFF():
|
||||
paths=importEntry.get()
|
||||
importcsv(paths,get_password())
|
||||
readl()
|
||||
importLabel.pack_forget()
|
||||
importBD.pack_forget()
|
||||
importEntry.pack_forget()
|
||||
tabview.pack(fill="both", expand=True,anchor='center')
|
||||
importB.pack(fill="x", expand=True,padx=5,pady=5, side="top",anchor="n")
|
||||
ExportB.pack(fill="x", expand=True,padx=5,pady=5, side="top",anchor="n")
|
||||
importEntry.delete(0, 'end')
|
||||
|
||||
importLabel=CTkLabel(window,text="Path:")
|
||||
importEntry=CTkEntry(window)
|
||||
def importDialog():
|
||||
tabview.pack_forget()
|
||||
importB.pack_forget()
|
||||
ExportB.pack_forget()
|
||||
importLabel.pack(fill="x", expand=True,padx=5,pady=5, side="top",anchor="n")
|
||||
importEntry.pack(fill="x", expand=True,padx=5,pady=5, side="top",anchor="n")
|
||||
importBD.pack(fill="x", expand=True,padx=5,pady=5, side="top",anchor="n")
|
||||
def Export():
|
||||
exportFF(get_password())
|
||||
ExportB=CTkButton(tab_read,command=Export,text="Export!")
|
||||
importB=CTkButton(tab_read,command=importDialog,text="Import!")
|
||||
|
||||
importBD=CTkButton(window,command=importFF,text="Import!")
|
||||
importB.pack(fill="x", expand=True,padx=5,pady=5, side="top",anchor="n")
|
||||
ExportB.pack(fill="x", expand=True,padx=5,pady=5, side="top",anchor="n")
|
||||
window.mainloop()
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
### Dependencies
|
||||
**Python**
|
||||
```sh
|
||||
pip install tk pyperclip qrcode customtkinter pyAesCrypt
|
||||
pip install tk pyperclip qrcode customtkinter pyAesCrypt stdiomask
|
||||
```
|
||||
|
||||
**On debian**
|
||||
|
||||
58
logics.py
58
logics.py
@ -1,3 +1,20 @@
|
||||
import os
|
||||
import sys
|
||||
scriptdir=os.path.abspath(__file__)
|
||||
try:
|
||||
paths=scriptdir.removesuffix('\logics.py')
|
||||
credpath=paths+"\credentials"
|
||||
credpathenc=paths+'\credentials.aes'
|
||||
assert os.path.isdir(direct), 'You fucked bro'
|
||||
|
||||
|
||||
except:
|
||||
paths=scriptdir.removesuffix('/logics.py')
|
||||
credpath=paths+"/credentials"
|
||||
credpathenc=paths+'/credentials.aes'
|
||||
|
||||
sys.path.append(paths)
|
||||
|
||||
def qr_share(site,login, password):
|
||||
import qrcode
|
||||
qr = qrcode.QRCode()
|
||||
@ -17,21 +34,21 @@ def qr_image(site,login, password,fg_color,bg_color):
|
||||
return True
|
||||
def encrypt(fpassword):
|
||||
import pyAesCrypt
|
||||
pyAesCrypt.encryptFile('credentials', 'credentials.aes', fpassword)
|
||||
pyAesCrypt.encryptFile(credpath, credpathenc, fpassword)
|
||||
import os
|
||||
os.remove("./credentials")
|
||||
os.remove(credpath)
|
||||
def decrypt(fpassword):
|
||||
import pyAesCrypt
|
||||
pyAesCrypt.decryptFile('credentials.aes', 'credentials', fpassword)
|
||||
pyAesCrypt.decryptFile(credpathenc, credpath, fpassword)
|
||||
import os
|
||||
os.remove("./credentials.aes")
|
||||
os.remove(credpathenc)
|
||||
|
||||
|
||||
def read_info_file(fpassword):
|
||||
info_list = []
|
||||
try:
|
||||
decrypt(fpassword)
|
||||
with open('credentials', 'r') as f:
|
||||
with open('credentials', 'r',encoding="utf-8") as f:
|
||||
for string in f.readlines():
|
||||
site = string.split('site: ')[1].split(' ')[0]
|
||||
login = string.split('login: ')[1].split(' ')[0]
|
||||
@ -51,7 +68,7 @@ def write_to_file(site,login, password,fpassword):
|
||||
pass
|
||||
from time import gmtime, strftime
|
||||
cur_time=strftime("%Y-%m-%d %H:%M:%S", gmtime()).replace(" ","_")
|
||||
with open('credentials', 'a') as f:
|
||||
with open(credpath, 'a') as f:
|
||||
f.write('site: '+site+' login: '+login +' password: '+ password +' date: '+(cur_time) + "\n")
|
||||
try:
|
||||
encrypt(fpassword)
|
||||
@ -61,7 +78,7 @@ def write_to_file(site,login, password,fpassword):
|
||||
def rewrite_to_file(lst,fpassword):
|
||||
try:
|
||||
decrypt(fpassword)
|
||||
with open('credentials', 'w') as f:
|
||||
with open(credpath, 'w') as f:
|
||||
for i in lst:
|
||||
f.write('site: '+i[0]+' login: '+i[1]+' password: '+i[2]+' date: '+i[3] + "\n")
|
||||
encrypt(fpassword)
|
||||
@ -75,3 +92,30 @@ def edit_info_file(index,new_site,new_login,new_pas,fpassword):
|
||||
lst[index][1]=new_login
|
||||
lst[index][2]=new_pas
|
||||
rewrite_to_file(lst,fpassword)
|
||||
|
||||
def importcsv(file,fpassword):
|
||||
import csv
|
||||
from datetime import datetime
|
||||
with open(file, newline='') as csvfile:
|
||||
reader = csv.DictReader(csvfile)
|
||||
for row in reader:
|
||||
site,login,password=row['url'], row['username'], row['password']
|
||||
try:
|
||||
time=int(row["timeCreated"][:-3:])
|
||||
time=datetime.utcfromtimestamp(time).strftime("%Y-%m-%d %H:%M:%S").replace(" ","_")
|
||||
write_to_file(site,login, password,fpassword,cur_time=time)
|
||||
except:
|
||||
write_to_file(site,login,password,fpassword)
|
||||
|
||||
def exportFF(fpassword):
|
||||
|
||||
lst=read_info_file(fpassword)
|
||||
lst=list(map(list, lst))
|
||||
import csv
|
||||
with open('logins.csv', 'w', newline='') as csvfile:
|
||||
fieldnames = ['url', 'username','password']
|
||||
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
|
||||
writer.writeheader()
|
||||
for i in lst:
|
||||
writer.writerow({'url': "https://"+i[0], 'username': i[1],"password": i[2]})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user