Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 68a2a0c252 |
37
otp.c
37
otp.c
@@ -101,22 +101,24 @@ int interactive_mode(void) {
|
||||
|
||||
while (1) {
|
||||
show_main_menu();
|
||||
int choice = get_user_choice(1, 6);
|
||||
char input[10];
|
||||
if (fgets(input, sizeof(input), stdin)) {
|
||||
char choice = toupper(input[0]);
|
||||
|
||||
switch (choice) {
|
||||
case 1:
|
||||
case 'G':
|
||||
handle_generate_menu();
|
||||
break;
|
||||
case 2:
|
||||
case 'E':
|
||||
handle_encrypt_menu();
|
||||
break;
|
||||
case 3:
|
||||
case 'D':
|
||||
handle_decrypt_menu();
|
||||
break;
|
||||
case 4:
|
||||
case 'L':
|
||||
list_available_pads();
|
||||
break;
|
||||
case 5: {
|
||||
case 'S': {
|
||||
printf("Enter pad checksum (or prefix): ");
|
||||
char input[MAX_HASH_LENGTH];
|
||||
if (fgets(input, sizeof(input), stdin)) {
|
||||
@@ -129,9 +131,16 @@ int interactive_mode(void) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
case 'X':
|
||||
printf("Goodbye!\n");
|
||||
return 0;
|
||||
default:
|
||||
printf("Invalid option. Please select G, E, D, L, S, or X.\n");
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
printf("Error reading input. Please try again.\n");
|
||||
continue;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
@@ -176,13 +185,13 @@ int command_line_mode(int argc, char* argv[]) {
|
||||
|
||||
void show_main_menu(void) {
|
||||
printf("=== Main Menu ===\n");
|
||||
printf("1. Generate new pad\n");
|
||||
printf("2. Encrypt message\n");
|
||||
printf("3. Decrypt message\n");
|
||||
printf("4. List available pads\n");
|
||||
printf("5. Show pad information\n");
|
||||
printf("6. Exit\n");
|
||||
printf("\nSelect option (1-6): ");
|
||||
printf("\033[4mG\033[0menerate new pad\n");
|
||||
printf("\033[4mE\033[0mncrypt message\n");
|
||||
printf("\033[4mD\033[0mecrypt message\n");
|
||||
printf("\033[4mL\033[0mist available pads\n");
|
||||
printf("\033[4mS\033[0mhow pad information\n");
|
||||
printf("E\033[4mx\033[0mit\n");
|
||||
printf("\nSelect option (G/E/D/L/S/X): ");
|
||||
}
|
||||
|
||||
int handle_generate_menu(void) {
|
||||
|
||||
Reference in New Issue
Block a user