Version v0.2.32 - implemented enhanced interactive filename editing for decrypt functionality
This commit is contained in:
1
decrypted.bin
Normal file
1
decrypted.bin
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Hello, this is a test file for encryption!
|
||||||
22
otp.c
22
otp.c
@@ -461,16 +461,28 @@ int handle_encrypt_menu(void) {
|
|||||||
|
|
||||||
int ascii_armor = (atoi(format_input) == 2) ? 1 : 0;
|
int ascii_armor = (atoi(format_input) == 2) ? 1 : 0;
|
||||||
|
|
||||||
// Ask for custom output filename (optional)
|
// Generate default output filename and use enhanced input function
|
||||||
printf("\nEnter output filename (or press Enter for default): ");
|
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];
|
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");
|
printf("Error: Failed to read input\n");
|
||||||
return 1;
|
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);
|
return encrypt_file(pad_input, input_file, output_filename, ascii_armor);
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
output.otp
Normal file
BIN
output.otp
Normal file
Binary file not shown.
1
test_input.txt
Normal file
1
test_input.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
This is a test file for encryption.
|
||||||
Reference in New Issue
Block a user