große weiterentwicklung
This commit is contained in:
parent
46c444990e
commit
23036dd928
7 changed files with 104 additions and 75 deletions
46
notizen/n.py
46
notizen/n.py
|
@ -22,18 +22,33 @@ def crypt(text, key_hash):
|
|||
def o(note,mode):
|
||||
return open(f"{n_path}{note}.txt",mode,encoding="utf-8")
|
||||
def nlist():
|
||||
string = ""
|
||||
notizen = []
|
||||
if os.listdir(n_path) == []:
|
||||
print("Noch keine Notizen")
|
||||
string += "Noch keine Notizen\n"
|
||||
else:
|
||||
print("Deine Notizen:")
|
||||
string += "Deine Notizen:\n"
|
||||
for a in os.listdir(n_path):
|
||||
notizen.append(f"{a}"[:-4])
|
||||
for n in notizen:
|
||||
print(f" - {n}:")
|
||||
string += f" - {n}:\n"
|
||||
datei = o(n,"r")
|
||||
print(crypt(datei.read() ,passwort))
|
||||
string += crypt(datei.read() ,passwort)+"\n"
|
||||
datei.close()
|
||||
return [string,notizen]
|
||||
|
||||
def neditadd(notiz=str,text=str):
|
||||
if not notiz+".txt" in os.listdir(n_path):
|
||||
if a_note+".txt" in os.listdir(n_path):
|
||||
back = "Notiz gibt es schon."
|
||||
return back
|
||||
back = "neue Notiz angelegt."
|
||||
else:
|
||||
back = "Erfolgreich gespeichert"
|
||||
datei = o(notiz,"w")
|
||||
datei.write(crypt(text, passwort))
|
||||
datei.close()
|
||||
return back
|
||||
|
||||
## variablen
|
||||
passwort = input("Passwort:")
|
||||
|
@ -49,7 +64,7 @@ if not os.path.exists(f"{n_path}n{tzeichen}"):
|
|||
n_path += "n"+tzeichen
|
||||
|
||||
## start
|
||||
print(""" Wikkommen zu n
|
||||
print(""" Willkommen zu n
|
||||
|
||||
ACHTUNG: Falls du dein Passwort falsch eingibst überprüfe
|
||||
erst ob deine Notizen richtig angezeigt werden sonnst falls
|
||||
|
@ -60,7 +75,7 @@ ACHTUNG: Es kann seine das einige Zeichen wie Umlaute falsch
|
|||
|
||||
Was möchtest du machen?: add, edit, read, list, help, exit.
|
||||
""")
|
||||
nlist()
|
||||
print(nlist()[0])
|
||||
|
||||
## programmschleife
|
||||
while 1:
|
||||
|
@ -92,13 +107,8 @@ ACHTUNG: Es kann seine Das einige Zeichen wie Umlaute falsch
|
|||
angezeigt werden können.""")
|
||||
if action == "edit": #edit
|
||||
a_note = input("Notiz Titel:")
|
||||
if not a_note+".txt" in os.listdir(n_path):
|
||||
print("Notiz nicht gefunden es wird eine neue angelegt.")
|
||||
datei = o(a_note,"w")
|
||||
text = input("bitte neuen Text einfügen:")
|
||||
datei.write(crypt(text, passwort))
|
||||
datei.close()
|
||||
print("Erfolgreich gespeichert")
|
||||
print(neditadd(a_note,text))
|
||||
if action == "read": #read
|
||||
a_note = input("Notiz Titel:")
|
||||
if a_note+".txt" in os.listdir(n_path):
|
||||
|
@ -109,14 +119,8 @@ ACHTUNG: Es kann seine Das einige Zeichen wie Umlaute falsch
|
|||
print("Notiz gibts nicht.")
|
||||
if action == "add": #add
|
||||
a_note = input("Notiz Titel:")
|
||||
if a_note+".txt" in os.listdir(n_path):
|
||||
print("Notiz gibt es schon.")
|
||||
else:
|
||||
datei = o(a_note,"w")
|
||||
text = input("bitte neuen Text einfügen:")
|
||||
datei.write(crypt(text , passwort))
|
||||
datei.close()
|
||||
print("Erfolgreich gespeichert")
|
||||
text = input("bitte neuen Text einfügen:")
|
||||
print(neditadd(a_note,text))
|
||||
if action == "delete": #delete
|
||||
a_note = input("Notiz Titel:")
|
||||
if a_note+".txt" in os.listdir(n_path):
|
||||
|
@ -128,7 +132,7 @@ ACHTUNG: Es kann seine Das einige Zeichen wie Umlaute falsch
|
|||
else:
|
||||
print("Notiz gibt es nicht.")
|
||||
if action == "list": #list
|
||||
nlist()
|
||||
print(nlist()[0])
|
||||
if action == "debug": #debug
|
||||
print(f"""Debug Informationen:
|
||||
n_path={n_path}
|
||||
|
|
1
notizen/n/test.txt
Normal file
1
notizen/n/test.txt
Normal file
|
@ -0,0 +1 @@
|
|||
UQVYY[ZS
|
128
notizen_w/n.py
128
notizen_w/n.py
|
@ -1,5 +1,6 @@
|
|||
import hashlib,os
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox
|
||||
#from tkinter import ttk
|
||||
|
||||
## funktionen
|
||||
|
@ -24,12 +25,33 @@ def crypt(text, key_hash):
|
|||
def o(note,mode):
|
||||
return open(f"{n_path}{note}.txt",mode,encoding="utf-8")
|
||||
def nlist():
|
||||
string = ""
|
||||
notizen = []
|
||||
if os.listdir(n_path) == []:
|
||||
print("Noch keine Notizen")
|
||||
string += "Noch keine Notizen\n"
|
||||
else:
|
||||
print("Deine Notizen:")
|
||||
string += "Deine Notizen:\n"
|
||||
for a in os.listdir(n_path):
|
||||
print(f" - {a}"[:-4])
|
||||
notizen.append(f"{a}"[:-4])
|
||||
for n in notizen:
|
||||
string += f" - {n}:\n"
|
||||
datei = o(n,"r")
|
||||
string += crypt(datei.read() ,passwort)+"\n"
|
||||
datei.close()
|
||||
return [string,notizen]
|
||||
|
||||
def neditadd(notiz=str,text=str):
|
||||
if not notiz+".txt" in os.listdir(n_path):
|
||||
if a_note+".txt" in os.listdir(n_path):
|
||||
back = "Notiz gibt es schon."
|
||||
return back
|
||||
back = "neue Notiz angelegt."
|
||||
else:
|
||||
back = "Erfolgreich gespeichert"
|
||||
datei = o(notiz,"w")
|
||||
datei.write(crypt(text, passwort))
|
||||
datei.close()
|
||||
return back
|
||||
|
||||
class tkf :
|
||||
def close_w() :
|
||||
|
@ -38,24 +60,40 @@ class tkf :
|
|||
w_welcome.destroy()
|
||||
passwort = sha512(passwort)
|
||||
|
||||
def nlist():
|
||||
global n_path
|
||||
if os.listdir(n_path) == []:
|
||||
print("hallo")
|
||||
l_mnotes = tk.Label(w_main, text="Noch keine Notizen")
|
||||
else:
|
||||
notes = "deine notizen:"
|
||||
for a in os.listdir(n_path):
|
||||
notes += "\n"+f" - {a}"[:-4]
|
||||
l_mnotes = tk.Label(text=notes)
|
||||
l_mnotes.pack()
|
||||
##############################lab.config
|
||||
def refresh_list():
|
||||
notiz_list.set(nlist()[0])
|
||||
def notiz_auswahl():
|
||||
w_auswahl = tk.Tk()
|
||||
l_wtauswahl = tk.Label(w_auswahl, text="Notiz:")
|
||||
l_wtauswahl.pack()
|
||||
tkf.dropdown(nlist()[1],w_auswahl)
|
||||
|
||||
def edit_notiz(title):
|
||||
notiz = o(title,"r")
|
||||
w_editnotiz = tk.Tk()
|
||||
|
||||
l_wttitle = tk.Label(w_editnotiz, text="Titel:")
|
||||
l_wtitle = tk.Entry(w_editnotiz)
|
||||
l_wtitle.insert(0,title)
|
||||
l_wtinhalt = tk.Label(w_editnotiz, text="Inhalt:")
|
||||
l_winhalt = tk.Entry(w_editnotiz)
|
||||
l_winhalt.insert(0,notiz.read())
|
||||
l_button_save = tk.Button(w_editnotiz, text="Save" ,command=tkf.close_w)
|
||||
l_button_cancel = tk.Button(w_editnotiz, text="Abbrechen" ,command=w_editnotiz.destroy)
|
||||
|
||||
l_wttitle.pack()
|
||||
l_wtitle.pack()
|
||||
l_wtinhalt.pack()
|
||||
l_winhalt.pack()
|
||||
l_button_save.pack()
|
||||
l_button_cancel.pack()
|
||||
|
||||
l_button_save.pack(fill="x")
|
||||
l_button_cancel.pack(fill="x")
|
||||
w_editnotiz.mainloop()
|
||||
|
||||
def help():
|
||||
w_popup = tk.Tk()
|
||||
w_popup.title("help")
|
||||
l_pop = tk.Label(w_popup, text="""Hilfe:
|
||||
|
||||
messagebox.showinfo("help", """Hilfe:
|
||||
edit = Bearbeite eine Notiz.
|
||||
read = Zeige eine Notiz an.
|
||||
add = Erstelle eine Notiz.
|
||||
|
@ -66,12 +104,8 @@ debug = Zeigt Debug Infos.
|
|||
exit = Beenden.
|
||||
|
||||
Bei Fehlern Bitte an Megamichi melden.""")
|
||||
l_pop.pack()
|
||||
w_popup.mainloop()
|
||||
def secure():
|
||||
w_popup = tk.Tk()
|
||||
|
||||
l_pop = tk.Label(w_popup, text="""Zur Sicherheit:
|
||||
messagebox.showinfo("sicherheit","""Zur Sicherheit:
|
||||
Es wir ein SHA-512 Hash aus dein Passwort erstellt.
|
||||
Und mit deinen Notizen und den auf die richtige Länge
|
||||
angepassten Hash wir ein One-Time-Pad angewendet.
|
||||
|
@ -82,20 +116,13 @@ du eine neue Notiz erstellst wird sie anderst verschlüsselt.
|
|||
|
||||
ACHTUNG: Es kann seine Das einige Zeichen wie Umlaute falsch
|
||||
angezeigt werden können.""")
|
||||
l_pop.pack()
|
||||
w_popup.mainloop()
|
||||
def debug():
|
||||
w_popup = tk.Tk()
|
||||
|
||||
l_pop = tk.Label(w_popup, text=f"""Debug Informationen:
|
||||
messagebox.showinfo("Debug",f"""Debug Informationen:
|
||||
n_path={n_path}
|
||||
pas_hash={passwort}""")
|
||||
l_pop.pack()
|
||||
w_popup.mainloop()
|
||||
|
||||
|
||||
|
||||
|
||||
def dropdown(liste,fenster):
|
||||
dropdown = tk.OptionMenu(fenster, selected_option, liste)
|
||||
dropdown.pack()
|
||||
|
||||
|
||||
## variablen
|
||||
|
@ -106,10 +133,10 @@ tzeichen = os.sep
|
|||
n_path += tzeichen
|
||||
if not os.path.exists(f"{n_path}n{tzeichen}"):
|
||||
os.makedirs(f"{n_path}n{tzeichen}")
|
||||
print("Notizenverzeichniss angelegt.")
|
||||
messagebox.showinfo("Verzeichniss","Notizenverzeichniss angelegt.")
|
||||
n_path += "n"+tzeichen
|
||||
|
||||
|
||||
tkf.edit_notiz("test")
|
||||
|
||||
# Welcome screen
|
||||
w_welcome = tk.Tk()
|
||||
|
@ -126,12 +153,12 @@ ACHTUNG: Es kann seine das einige Zeichen wie Umlaute falsch
|
|||
|
||||
Passwort:""")
|
||||
l_wpassword = tk.Entry(w_welcome)
|
||||
selected_option = tk.StringVar()
|
||||
l_wbutton = tk.Button(w_welcome, text="Start" ,command=tkf.close_w)
|
||||
l_wtext.pack()
|
||||
l_wpassword.pack()
|
||||
l_wbutton.pack(fill="x")
|
||||
w_welcome.mainloop()
|
||||
|
||||
# main fenster
|
||||
|
||||
w_main = tk.Tk()
|
||||
|
@ -144,13 +171,10 @@ w_main.config(menu=menu)
|
|||
|
||||
nmenu = tk.Menu(menu, tearoff=0)
|
||||
menu.add_cascade(label="n", menu=nmenu)
|
||||
nmenu.add_command(label="New", command=tkf.nlist)
|
||||
nmenu.add_command(label="refresh", command=tkf.nlist)
|
||||
nmenu.add_command(label="edit", command=tkf.nlist)
|
||||
nmenu.add_command(label="read", command=tkf.nlist)
|
||||
nmenu.add_command(label="delete", command=tkf.nlist)
|
||||
|
||||
nmenu.add_command(label="delete", command=tkf.nlist)
|
||||
#nmenu.add_command(label="New", command=)
|
||||
nmenu.add_command(label="refresh", command=tkf.refresh_list)
|
||||
nmenu.add_command(label="edit", command=tkf.edit_notiz)
|
||||
#nmenu.add_command(label="delete", command=tkf.nlist)
|
||||
|
||||
moremenu = tk.Menu(menu, tearoff=0)
|
||||
menu.add_cascade(label="more", menu=moremenu)
|
||||
|
@ -158,17 +182,13 @@ moremenu.add_command(label="secure", command=tkf.secure)
|
|||
moremenu.add_command(label="help", command=tkf.help)
|
||||
moremenu.add_command(label="debug", command=tkf.debug)
|
||||
|
||||
if os.listdir(n_path) == []:
|
||||
print("hallo")
|
||||
l_mnotes = tk.Label(w_main, text="Noch keine Notizen")
|
||||
else:
|
||||
notes = "deine notizen:"
|
||||
for a in os.listdir(n_path):
|
||||
notes += "\n"+f" - {a}"[:-4]
|
||||
l_mnotes = tk.Label(text=notes)
|
||||
l_mnotes.pack()
|
||||
|
||||
notiz_list = tk.StringVar()
|
||||
|
||||
|
||||
notiz_list.set(nlist()[0])
|
||||
l_nlist = tk.Label(w_main, textvariable=notiz_list)
|
||||
l_nlist.pack()
|
||||
|
||||
w_welcome.mainloop()
|
||||
|
||||
|
|
2
notizen_w/n/banane.txt
Normal file
2
notizen_w/n/banane.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
^S
|
||||
QT^R
WZ
|
1
notizen_w/n/dodel.txt
Normal file
1
notizen_w/n/dodel.txt
Normal file
|
@ -0,0 +1 @@
|
|||
ZQXZYZYW
|
1
notizen_w/n/test.txt
Normal file
1
notizen_w/n/test.txt
Normal file
|
@ -0,0 +1 @@
|
|||
UQVYY[ZS
|
BIN
notizen_w/n/wurst.txt
Normal file
BIN
notizen_w/n/wurst.txt
Normal file
Binary file not shown.
Loading…
Reference in a new issue