"echo":"echo <string content> ( 'string_content' = any text to be echoed )",
"echo":"echo <string content> ( 'string_content' = any text to be echoed )",
"dbg":"dbg ( Prints a debug output of the manager's state )",
"dbg":"dbg ( Prints a debug output of the manager's state )",
"list":"list [ <label> <password> ](Prints the passwords currently stored 'label' = the password you want to decrypt)",
"list":"list [ <label> <password> ](Prints the passwords currently stored 'label' = the password you want to decrypt)",
"save":"save - Saves the state to the file originally inputted.",# TODO: make it possible to save to a new file
"save":"save <filename> - Saves the state to the file originally inputted or the file provided.",
"drop":"drop <label> - deletes the selected label from the list of passwords. This can be undone with the 'undo' command, however if 'drop' is used on an already deleted password, the password is removed forever from the database.",
"drop":"drop <label> - deletes the selected label from the list of passwords. This can be undone with the 'undo' command, however if 'drop' is used on an already deleted password, the password is removed forever from the database.",
"undo":"undo - undoes the latest deletion/modification",
"undo":"undo - undoes the latest deletion/modification",
"history":"history - prints all the deleted passwords",
"history":"history - prints all the deleted passwords",
...
@@ -306,7 +306,9 @@ class State:
...
@@ -306,7 +306,9 @@ class State:
'<p.label>,<p.encrypted_password>' <-- same format as caesar, just in a different section
'<p.label>,<p.encrypted_password>' <-- same format as caesar, just in a different section
<end>
<end>
"""
"""
defsave(self):
defsave(self,filepath=None):
iffilepathisNone:
filepath=self.filepath
content=self.head+"\n"
content=self.head+"\n"
content+=f"{self.rsa_key}"+"\n"
content+=f"{self.rsa_key}"+"\n"
forl,pinself.passwords.items():
forl,pinself.passwords.items():
...
@@ -324,7 +326,7 @@ class State:
...
@@ -324,7 +326,7 @@ class State:
content+=f"rm({l}),{p.encrypt()}\n"
content+=f"rm({l}),{p.encrypt()}\n"
else:
else:
content+=f"{l},{p.encrypt()}\n"
content+=f"{l},{p.encrypt()}\n"
file=open(self.filepath,'w')
file=open(filepath,'w')
file.write(content)
file.write(content)
file.close()
file.close()
...
@@ -461,9 +463,12 @@ def main():
...
@@ -461,9 +463,12 @@ def main():
elifcommand=="dbg":
elifcommand=="dbg":
print(vars(state))
print(vars(state))
elifcommand=="save"orcommand=="s":
elifcommand=="save"orcommand=="s":
file=None
iflen(args)>1:
file=args[1]
try:
try:
state.save()
state.save(file)
print(f"State saved to {filepath}!")
print(f"State saved to {file if file is not None else state.filepath}!")
except:
except:
print("There was an error saving, maybe back up your stuff now. Sorry")
print("There was an error saving, maybe back up your stuff now. Sorry")