From 2d6546ab833f8937b97cdee9b4f88c3a31d76201 Mon Sep 17 00:00:00 2001 From: Laan Tungir Date: Wed, 13 Aug 2025 11:30:29 -0400 Subject: [PATCH] Version v0.2.32 - implemented enhanced interactive filename editing for decrypt functionality --- decrypted.bin | 1 + otp.c | 22 +++++++++++++++++----- output.otp | Bin 0 -> 101 bytes test_input.txt | 1 + 4 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 decrypted.bin create mode 100644 output.otp create mode 100644 test_input.txt diff --git a/decrypted.bin b/decrypted.bin new file mode 100644 index 0000000..e07046f --- /dev/null +++ b/decrypted.bin @@ -0,0 +1 @@ +Hello, this is a test file for encryption! diff --git a/otp.c b/otp.c index cdd715b..8996132 100644 --- a/otp.c +++ b/otp.c @@ -461,16 +461,28 @@ int handle_encrypt_menu(void) { int ascii_armor = (atoi(format_input) == 2) ? 1 : 0; - // Ask for custom output filename (optional) - printf("\nEnter output filename (or press Enter for default): "); + // Generate default output filename and use enhanced input function + char default_output[512]; + snprintf(default_output, sizeof(default_output), "%s.decrypted", input_file); + + // Remove common encrypted extensions to get a better default + if (strstr(default_output, ".otp.asc.decrypted")) { + // Replace .otp.asc.decrypted with original extension or no extension + char* ext_pos = strstr(default_output, ".otp.asc.decrypted"); + *ext_pos = '\0'; + } else if (strstr(default_output, ".otp.decrypted")) { + // Replace .otp.decrypted with original extension or no extension + char* ext_pos = strstr(default_output, ".otp.decrypted"); + *ext_pos = '\0'; + } + char output_file[512]; - if (!fgets(output_file, sizeof(output_file), stdin)) { + if (get_filename_with_default("Output filename:", default_output, output_file, sizeof(output_file)) != 0) { printf("Error: Failed to read input\n"); return 1; } - output_file[strcspn(output_file, "\n")] = 0; - const char* output_filename = (strlen(output_file) > 0) ? output_file : NULL; + const char* output_filename = output_file; return encrypt_file(pad_input, input_file, output_filename, ascii_armor); } diff --git a/output.otp b/output.otp new file mode 100644 index 0000000000000000000000000000000000000000..bfca1c0fa69e65cc61ca693369d203ca16992464 GIT binary patch literal 101 zcmeYd31DDkxNv1jr>V2YhTfiPBM*@qM;QcI^yV(9*O_i_v@nZPKstp10vZ|_7_^~m x-F+orn+``u+q5Mwx>zvTK+7pj