Compare commits

..

No commits in common. "Reworked" and "main" have entirely different histories.

3 changed files with 13 additions and 104 deletions

View File

@ -1,26 +1,12 @@
from customtkinter import CTkLabel,CTkButton,CTkEntry,CTkScrollableFrame,CTkTabview,CTk,get_appearance_mode,set_widget_scaling,set_window_scaling from customtkinter import CTkLabel,CTkButton,CTkEntry,CTkScrollableFrame,CTkTabview,CTk,get_appearance_mode
from logics import *
from tkinter import PhotoImage from tkinter import PhotoImage
import os import os
import sys
window = CTk() window = CTk()
scriptdir=os.path.abspath(__file__)
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") 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'))
theme=get_appearance_mode() theme=get_appearance_mode()
if theme=="Dark": if theme=="Dark":
bg_color="#242424" bg_color="#242424"
@ -28,10 +14,6 @@ if theme=="Dark":
else: else:
fg_color="#242424" fg_color="#242424"
bg_color="#dbdbdb" 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) tabview = CTkTabview(window)
tab_write=tabview.add("Write") # add tab at the end tab_write=tabview.add("Write") # add tab at the end
tab_read=tabview.add("Read") # add tab at the end tab_read=tabview.add("Read") # add tab at the end
@ -228,33 +210,4 @@ Site_label.grid(row=0, column=0,padx=12,pady=10)
Login_label.grid(row=1, 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) Password_label.grid(row=2, column=0,padx=12,pady=10)
SaveBut.grid(row=3, column=1,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() window.mainloop()

View File

@ -4,7 +4,7 @@
### Dependencies ### Dependencies
**Python** **Python**
```sh ```sh
pip install tk pyperclip qrcode customtkinter pyAesCrypt stdiomask pip install tk pyperclip qrcode customtkinter pyAesCrypt
``` ```
**On debian** **On debian**

View File

@ -1,20 +1,3 @@
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): def qr_share(site,login, password):
import qrcode import qrcode
qr = qrcode.QRCode() qr = qrcode.QRCode()
@ -34,21 +17,21 @@ def qr_image(site,login, password,fg_color,bg_color):
return True return True
def encrypt(fpassword): def encrypt(fpassword):
import pyAesCrypt import pyAesCrypt
pyAesCrypt.encryptFile(credpath, credpathenc, fpassword) pyAesCrypt.encryptFile('credentials', 'credentials.aes', fpassword)
import os import os
os.remove(credpath) os.remove("./credentials")
def decrypt(fpassword): def decrypt(fpassword):
import pyAesCrypt import pyAesCrypt
pyAesCrypt.decryptFile(credpathenc, credpath, fpassword) pyAesCrypt.decryptFile('credentials.aes', 'credentials', fpassword)
import os import os
os.remove(credpathenc) os.remove("./credentials.aes")
def read_info_file(fpassword): def read_info_file(fpassword):
info_list = [] info_list = []
try: try:
decrypt(fpassword) decrypt(fpassword)
with open('credentials', 'r',encoding="utf-8") as f: with open('credentials', 'r') as f:
for string in f.readlines(): for string in f.readlines():
site = string.split('site: ')[1].split(' ')[0] site = string.split('site: ')[1].split(' ')[0]
login = string.split('login: ')[1].split(' ')[0] login = string.split('login: ')[1].split(' ')[0]
@ -68,7 +51,7 @@ def write_to_file(site,login, password,fpassword):
pass pass
from time import gmtime, strftime from time import gmtime, strftime
cur_time=strftime("%Y-%m-%d %H:%M:%S", gmtime()).replace(" ","_") cur_time=strftime("%Y-%m-%d %H:%M:%S", gmtime()).replace(" ","_")
with open(credpath, 'a') as f: with open('credentials', 'a') as f:
f.write('site: '+site+' login: '+login +' password: '+ password +' date: '+(cur_time) + "\n") f.write('site: '+site+' login: '+login +' password: '+ password +' date: '+(cur_time) + "\n")
try: try:
encrypt(fpassword) encrypt(fpassword)
@ -78,7 +61,7 @@ def write_to_file(site,login, password,fpassword):
def rewrite_to_file(lst,fpassword): def rewrite_to_file(lst,fpassword):
try: try:
decrypt(fpassword) decrypt(fpassword)
with open(credpath, 'w') as f: with open('credentials', 'w') as f:
for i in lst: for i in lst:
f.write('site: '+i[0]+' login: '+i[1]+' password: '+i[2]+' date: '+i[3] + "\n") f.write('site: '+i[0]+' login: '+i[1]+' password: '+i[2]+' date: '+i[3] + "\n")
encrypt(fpassword) encrypt(fpassword)
@ -92,30 +75,3 @@ def edit_info_file(index,new_site,new_login,new_pas,fpassword):
lst[index][1]=new_login lst[index][1]=new_login
lst[index][2]=new_pas lst[index][2]=new_pas
rewrite_to_file(lst,fpassword) 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]})