diff --git a/otp.c b/otp.c index 99cdd2c..2947ebe 100644 --- a/otp.c +++ b/otp.c @@ -2409,9 +2409,40 @@ int pipe_mode(int argc, char* argv[], const char* piped_text) { (void)argc; // Suppress unused parameter warning (void)argv; // Suppress unused parameter warning - printf("Piped text received: \"%s\"\n\n", piped_text); + printf("Piped text received: \"%s\"\n", piped_text); - // List available pads for selection + // Check if we have a default pad configured + char* default_pad = get_default_pad_path(); + if (default_pad) { + // Verify the default pad exists and extract checksum + if (access(default_pad, R_OK) == 0) { + // Extract checksum from pad filename + char* filename = strrchr(default_pad, '/'); + if (!filename) filename = default_pad; + else filename++; // Skip the '/' + + // Extract checksum (remove .pad extension) + if (strlen(filename) >= 68 && strstr(filename, ".pad")) { + char pad_checksum[65]; + strncpy(pad_checksum, filename, 64); + pad_checksum[64] = '\0'; + + printf("Using default pad: %.16s...\n\n", pad_checksum); + free(default_pad); + + // Encrypt using the default pad + return encrypt_text(pad_checksum, piped_text); + } + } + + printf("Warning: Default pad not found or invalid: %s\n", default_pad); + free(default_pad); + // Fall through to interactive selection + } + + printf("No default pad configured.\n\n"); + + // List available pads for interactive selection int pad_count = list_available_pads(); if (pad_count == 0) { printf("No pads available. Generate a pad first.\n");