Compare commits

..

1 Commits

Author SHA1 Message Date
68a2a0c252 Version v0.2.8 - Automatic version increment 2025-08-10 09:14:23 -04:00

79
otp.c
View File

@@ -101,37 +101,46 @@ int interactive_mode(void) {
while (1) { while (1) {
show_main_menu(); show_main_menu();
int choice = get_user_choice(1, 6); char input[10];
if (fgets(input, sizeof(input), stdin)) {
switch (choice) { char choice = toupper(input[0]);
case 1:
handle_generate_menu(); switch (choice) {
break; case 'G':
case 2: handle_generate_menu();
handle_encrypt_menu(); break;
break; case 'E':
case 3: handle_encrypt_menu();
handle_decrypt_menu(); break;
break; case 'D':
case 4: handle_decrypt_menu();
list_available_pads(); break;
break; case 'L':
case 5: { list_available_pads();
printf("Enter pad checksum (or prefix): "); break;
char input[MAX_HASH_LENGTH]; case 'S': {
if (fgets(input, sizeof(input), stdin)) { printf("Enter pad checksum (or prefix): ");
input[strcspn(input, "\n")] = 0; char input[MAX_HASH_LENGTH];
char* hash = find_pad_by_prefix(input); if (fgets(input, sizeof(input), stdin)) {
if (hash) { input[strcspn(input, "\n")] = 0;
show_pad_info(hash); char* hash = find_pad_by_prefix(input);
free(hash); if (hash) {
show_pad_info(hash);
free(hash);
}
} }
break;
} }
break; case 'X':
printf("Goodbye!\n");
return 0;
default:
printf("Invalid option. Please select G, E, D, L, S, or X.\n");
continue;
} }
case 6: } else {
printf("Goodbye!\n"); printf("Error reading input. Please try again.\n");
return 0; continue;
} }
printf("\n"); printf("\n");
} }
@@ -176,13 +185,13 @@ int command_line_mode(int argc, char* argv[]) {
void show_main_menu(void) { void show_main_menu(void) {
printf("=== Main Menu ===\n"); printf("=== Main Menu ===\n");
printf("1. Generate new pad\n"); printf("\033[4mG\033[0menerate new pad\n");
printf("2. Encrypt message\n"); printf("\033[4mE\033[0mncrypt message\n");
printf("3. Decrypt message\n"); printf("\033[4mD\033[0mecrypt message\n");
printf("4. List available pads\n"); printf("\033[4mL\033[0mist available pads\n");
printf("5. Show pad information\n"); printf("\033[4mS\033[0mhow pad information\n");
printf("6. Exit\n"); printf("E\033[4mx\033[0mit\n");
printf("\nSelect option (1-6): "); printf("\nSelect option (G/E/D/L/S/X): ");
} }
int handle_generate_menu(void) { int handle_generate_menu(void) {