c
This commit is contained in:
parent
464f81b059
commit
80054cf54a
3 changed files with 45 additions and 108 deletions
152
notizen_w/n.py
152
notizen_w/n.py
|
@ -42,7 +42,7 @@ def nlist():
|
||||||
|
|
||||||
def neditadd(notiz=str,text=str):
|
def neditadd(notiz=str,text=str):
|
||||||
if not notiz+".txt" in os.listdir(n_path):
|
if not notiz+".txt" in os.listdir(n_path):
|
||||||
if a_note+".txt" in os.listdir(n_path):
|
if notiz+".txt" in os.listdir(n_path):
|
||||||
back = "Notiz gibt es schon."
|
back = "Notiz gibt es schon."
|
||||||
return back
|
return back
|
||||||
back = "neue Notiz angelegt."
|
back = "neue Notiz angelegt."
|
||||||
|
@ -52,12 +52,17 @@ def neditadd(notiz=str,text=str):
|
||||||
datei.write(crypt(text, passwort))
|
datei.write(crypt(text, passwort))
|
||||||
datei.close()
|
datei.close()
|
||||||
return back
|
return back
|
||||||
|
|
||||||
class eigene_fenster:
|
class eigene_fenster:
|
||||||
def welcome_w():
|
def welcome_w():
|
||||||
w_welcome = tk.Tk()
|
w_welcome = tk.Tk()
|
||||||
w_welcome.title("Welcome zu n")
|
w_welcome.title("Welcome zu n")
|
||||||
w_welcome.geometry("450x300")
|
w_welcome.geometry("450x300")
|
||||||
|
def ok():
|
||||||
|
global passwort
|
||||||
|
passwort = l_wpassword.get()
|
||||||
|
passwort = sha512(passwort)
|
||||||
|
w_welcome.destroy()
|
||||||
l_wtext = tk.Label(w_welcome, text="""
|
l_wtext = tk.Label(w_welcome, text="""
|
||||||
ACHTUNG: Falls du dein Passwort falsch eingibst überprüfe
|
ACHTUNG: Falls du dein Passwort falsch eingibst überprüfe
|
||||||
erst ob deine Notizen richtig angezeigt werden sonnst falls
|
erst ob deine Notizen richtig angezeigt werden sonnst falls
|
||||||
|
@ -68,18 +73,22 @@ ACHTUNG: Es kann seine das einige Zeichen wie Umlaute falsch
|
||||||
|
|
||||||
Passwort:""")
|
Passwort:""")
|
||||||
l_wpassword = tk.Entry(w_welcome)
|
l_wpassword = tk.Entry(w_welcome)
|
||||||
l_wbutton = tk.Button(w_welcome, text="Start" ,command=w_welcome.destroy)
|
l_wbutton = tk.Button(w_welcome, text="Start" ,command=ok)
|
||||||
l_wtext.pack()
|
l_wtext.pack()
|
||||||
l_wpassword.pack()
|
l_wpassword.pack()
|
||||||
l_wbutton.pack(fill="x")
|
l_wbutton.pack(fill="x")
|
||||||
w_welcome.mainloop()
|
w_welcome.mainloop()
|
||||||
#w_welcome.destroy()
|
|
||||||
passwort = "hallo" #l_wpassword.get()
|
|
||||||
passwort = sha512(passwort)
|
|
||||||
return passwort
|
return passwort
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
class actions():
|
||||||
|
def edit():
|
||||||
|
notiz = eigene_dialoge.notiz_auswahl()
|
||||||
|
write_note = eigene_dialoge.notiz_dialog(notiz)
|
||||||
|
info = neditadd(write_note[0],write_note[1])
|
||||||
|
messagebox("Notiz",info)
|
||||||
|
def new():
|
||||||
|
pass
|
||||||
w_main = tk.Tk()
|
w_main = tk.Tk()
|
||||||
w_main.title("n")
|
w_main.title("n")
|
||||||
w_main.geometry("800x600")
|
w_main.geometry("800x600")
|
||||||
|
@ -89,9 +98,9 @@ Passwort:""")
|
||||||
|
|
||||||
nmenu = tk.Menu(menu, tearoff=0)
|
nmenu = tk.Menu(menu, tearoff=0)
|
||||||
menu.add_cascade(label="n", menu=nmenu)
|
menu.add_cascade(label="n", menu=nmenu)
|
||||||
#nmenu.add_command(label="New", command=)
|
nmenu.add_command(label="New", command=eigene_dialoge.notiz_dialog)
|
||||||
nmenu.add_command(label="refresh", command=tkf.refresh_list)
|
nmenu.add_command(label="refresh", command=tkf.refresh_list)
|
||||||
nmenu.add_command(label="edit", command=eigene_dialoge.notiz_dialog)
|
nmenu.add_command(label="edit", command=actions.edit)
|
||||||
#nmenu.add_command(label="delete", command=tkf.nlist)
|
#nmenu.add_command(label="delete", command=tkf.nlist)
|
||||||
|
|
||||||
moremenu = tk.Menu(menu, tearoff=0)
|
moremenu = tk.Menu(menu, tearoff=0)
|
||||||
|
@ -109,12 +118,14 @@ Passwort:""")
|
||||||
|
|
||||||
class eigene_dialoge:
|
class eigene_dialoge:
|
||||||
def notiz_dialog(title):
|
def notiz_dialog(title):
|
||||||
notiz = "inhalt"#o(title,"r")
|
notiz = o(title,"r")
|
||||||
w_editnotiz = tk.Tk()
|
w_editnotiz = tk.Tk()
|
||||||
def cancel():
|
def cancel():
|
||||||
w_editnotiz.destroy
|
w_editnotiz.destroy()
|
||||||
def ok():
|
def ok():
|
||||||
w_editnotiz.destroy
|
global ret
|
||||||
|
ret = [l_wtitle.get(),l_winhalt.get()]
|
||||||
|
w_editnotiz.destroy()
|
||||||
|
|
||||||
l_wttitle = tk.Label(w_editnotiz, text="Titel:")
|
l_wttitle = tk.Label(w_editnotiz, text="Titel:")
|
||||||
l_wtitle = tk.Entry(w_editnotiz)
|
l_wtitle = tk.Entry(w_editnotiz)
|
||||||
|
@ -135,17 +146,28 @@ class eigene_dialoge:
|
||||||
l_button_save.pack(fill="x")
|
l_button_save.pack(fill="x")
|
||||||
l_button_cancel.pack(fill="x")
|
l_button_cancel.pack(fill="x")
|
||||||
w_editnotiz.mainloop()
|
w_editnotiz.mainloop()
|
||||||
return [l_wtitle.get(),l_winhalt.get()]
|
return ret
|
||||||
|
def notiz_auswahl():
|
||||||
|
def done():
|
||||||
|
global ret
|
||||||
|
ret = gewählt.get()
|
||||||
|
auswahl.destroy()
|
||||||
|
auswahl = tk.Tk()
|
||||||
|
gewählt = tk.StringVar(auswahl)
|
||||||
|
gewählt.set("Notiz auswählen")
|
||||||
|
tauswahl = tk.Label(auswahl, text="Notiz:")
|
||||||
|
tauswahl.pack()
|
||||||
|
dropdown = tk.OptionMenu(auswahl, gewählt, *nlist()[1])
|
||||||
|
dropdown.pack()
|
||||||
|
button = tk.Button(auswahl,text="Auswählen",command=done)
|
||||||
|
button.pack(fill="x")
|
||||||
|
auswahl.mainloop()
|
||||||
|
return ret
|
||||||
|
|
||||||
class tkf :
|
class tkf :
|
||||||
|
|
||||||
|
|
||||||
def refresh_list():
|
def refresh_list():
|
||||||
notiz_list.set(nlist()[0])
|
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 help():
|
def help():
|
||||||
messagebox.showinfo("help", """Hilfe:
|
messagebox.showinfo("help", """Hilfe:
|
||||||
|
@ -175,13 +197,9 @@ ACHTUNG: Es kann seine Das einige Zeichen wie Umlaute falsch
|
||||||
messagebox.showinfo("Debug",f"""Debug Informationen:
|
messagebox.showinfo("Debug",f"""Debug Informationen:
|
||||||
n_path={n_path}
|
n_path={n_path}
|
||||||
pas_hash={passwort}""")
|
pas_hash={passwort}""")
|
||||||
def dropdown(liste,fenster):
|
|
||||||
dropdown = tk.OptionMenu(fenster, selected_option, liste)
|
|
||||||
dropdown.pack()
|
|
||||||
|
|
||||||
|
|
||||||
## variablen
|
## variablen
|
||||||
passwort = ""
|
passwort = "HALIHALLO"
|
||||||
##notizen pfad
|
##notizen pfad
|
||||||
n_path = os.path.dirname(os.path.abspath(__file__))
|
n_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
tzeichen = os.sep
|
tzeichen = os.sep
|
||||||
|
@ -191,89 +209,9 @@ if not os.path.exists(f"{n_path}n{tzeichen}"):
|
||||||
messagebox.showinfo("Verzeichniss","Notizenverzeichniss angelegt.")
|
messagebox.showinfo("Verzeichniss","Notizenverzeichniss angelegt.")
|
||||||
n_path += "n"+tzeichen
|
n_path += "n"+tzeichen
|
||||||
|
|
||||||
print(eigene_dialoge.notiz_dialog("test"))
|
#eigene_dialoge.notiz_auswahl()
|
||||||
exit()
|
#exit()
|
||||||
# Welcome screen
|
# Welcome screen
|
||||||
passwort = eigene_fenster.welcome_w()
|
passwort = eigene_fenster.welcome_w()
|
||||||
# main fenster
|
# main fenster
|
||||||
|
|
||||||
eigene_fenster.main()
|
eigene_fenster.main()
|
||||||
|
|
||||||
## start
|
|
||||||
exit()
|
|
||||||
nlist()
|
|
||||||
|
|
||||||
## programmschleife
|
|
||||||
while 1:
|
|
||||||
action = input(">")
|
|
||||||
if action == "help": #help ##
|
|
||||||
print("""Hilfe:
|
|
||||||
|
|
||||||
edit = Bearbeite eine Notiz.
|
|
||||||
read = Zeige eine Notiz an.
|
|
||||||
add = Erstelle eine Notiz.
|
|
||||||
delete = Notiz löschen.
|
|
||||||
list = Zeigt dir deine Notizen nochmals an.
|
|
||||||
secure = Wie funktioniert die verschlüsselung.
|
|
||||||
debug = Zeigt Debug Infos.
|
|
||||||
exit = Beenden.
|
|
||||||
|
|
||||||
Bei Fehlern Bitte an Megamichi melden.""")
|
|
||||||
if action == "secure": #secure ##
|
|
||||||
print("""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.
|
|
||||||
|
|
||||||
ACHTUNG: Falls du dein Passwort falsch eingibst überprüfe
|
|
||||||
erst ob deine Notizen richtig angezeigt werden sonst falls
|
|
||||||
du eine neue Notiz erstellst wird sie anderst verschlüsselt.
|
|
||||||
|
|
||||||
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")
|
|
||||||
if action == "read": #read #
|
|
||||||
a_note = input("Notiz Titel:")
|
|
||||||
if a_note+".txt" in os.listdir(n_path):
|
|
||||||
datei = o(a_note,"r")
|
|
||||||
print(crypt(datei.read() ,passwort))
|
|
||||||
datei.close
|
|
||||||
else:
|
|
||||||
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")
|
|
||||||
if action == "delete": #delete
|
|
||||||
a_note = input("Notiz Titel:")
|
|
||||||
if a_note+".txt" in os.listdir(n_path):
|
|
||||||
if input("Wirklich löschen?:") == "ja":
|
|
||||||
os.remove(f"{n_path}{a_note}.txt")
|
|
||||||
print("Notiz gelöscht")
|
|
||||||
else:
|
|
||||||
print("Notiz nicht gelöscht")
|
|
||||||
else:
|
|
||||||
print("Notiz gibt es nicht.")
|
|
||||||
if action == "list": #list ##
|
|
||||||
nlist()
|
|
||||||
if action == "debug": #debug #
|
|
||||||
print(f"""Debug Informationen:
|
|
||||||
n_path={n_path}
|
|
||||||
pas_hash={passwort}""")
|
|
||||||
if action == "exit": #exit ####
|
|
||||||
print("Bye")
|
|
||||||
exit()
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
ZQXZYZYW
|
|
Binary file not shown.
Loading…
Reference in a new issue