diff --git a/otp.c b/otp.c index 215de95..9ce67a8 100644 --- a/otp.c +++ b/otp.c @@ -2404,13 +2404,24 @@ int pipe_mode(int argc, char* argv[], const char* piped_text) { return 1; } + // Reopen stdin from the controlling terminal for interactive input + FILE* tty = fopen("/dev/tty", "r"); + if (!tty) { + printf("Error: Cannot open terminal for input\n"); + return 1; + } + printf("\nEnter pad selection (number, checksum, or prefix): "); + fflush(stdout); + char pad_input[MAX_HASH_LENGTH]; - if (!fgets(pad_input, sizeof(pad_input), stdin)) { + if (!fgets(pad_input, sizeof(pad_input), tty)) { printf("Error: Failed to read pad selection\n"); + fclose(tty); return 1; } pad_input[strcspn(pad_input, "\n")] = 0; + fclose(tty); // Encrypt the piped text return encrypt_text(pad_input, piped_text);