WIP editor

Can only read the password no safe for edit
This commit is contained in:
Nikola Petrov
2024-07-22 11:52:52 +02:00
parent 5b0dcb23ea
commit ae7c8571b4
9 changed files with 1156 additions and 1 deletions

View File

@@ -13,6 +13,7 @@
#include "func.hpp"
#include "buffer.hpp"
#include "aes256.hpp"
#include "editor.hpp"
void print_args()
{
@@ -27,6 +28,7 @@ void print_args()
printf(" -s <label> show password for this label\n");
printf(" -u <label> update username for this label\n");
printf(" -n <label> update label name\n");
printf(" -e <label> open editor, password as note\n");
printf(" -l list all labels\n");
printf(" -p print all passwords\n");
printf(" -c change master password\n");
@@ -84,6 +86,8 @@ Arg get_args(int argc, char **argv, char **label)
return Arg::Name;
case 'f':
return Arg::File;
case 'e':
return Arg::Editor;
default:
return Arg::Error;
@@ -358,4 +362,21 @@ void arg_file(Buffer &decrypted_buffer, Buffer &encrypted_buffer, const char *la
void arg_size(Buffer &encrypted_buffer)
{
printf("File size is: %zuB\n", encrypted_buffer.taken);
}
void arg_editor(Buffer &decrypted_buffer, Buffer &encrypted_buffer, const char *label_to_del, std::string &key)
{
int pass = find_logininfo_in_buffer(decrypted_buffer, label_to_del);
if (pass < 0)
{
printf("Password not found\n");
return;
}
LoginInfoPointer lip = get_logininfo_pointer_from_buffer(decrypted_buffer, pass);
edit_file(lip.password);
// delete_logininfo_from_buffer(decrypted_buffer, pass);
// Aes256::encrypt(key, decrypted_buffer, encrypted_buffer);
// encrypted_buffer.save_to_file();
}