From 21b3c4de52f6282f38f94882a144d379eebd3ab0 Mon Sep 17 00:00:00 2001 From: Laan Tungir Date: Thu, 14 Aug 2025 12:29:23 -0400 Subject: [PATCH] Version v0.2.79 - Fixed decrypt output - added newline and flush to ensure proper output --- otp.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/otp.c b/otp.c index 46544ae..3cce4d6 100644 --- a/otp.c +++ b/otp.c @@ -1626,59 +1626,42 @@ int decrypt_text_silent(const char* pad_identifier, const char* encrypted_messag char base64_data[MAX_INPUT_SIZE * 2] = {0}; int in_data_section = 0; - fprintf(stderr, "DEBUG: decrypt_text_silent called\n"); - fprintf(stderr, "DEBUG: encrypted_message is %s\n", encrypted_message ? "not NULL" : "NULL"); - if (encrypted_message != NULL) { - fprintf(stderr, "DEBUG: Message length: %lu\n", strlen(encrypted_message)); - fprintf(stderr, "DEBUG: First 50 chars: %.50s\n", encrypted_message); - // Parse provided encrypted message char *message_copy = strdup(encrypted_message); char *line_ptr = strtok(message_copy, "\n"); int found_begin = 0; while (line_ptr != NULL) { - fprintf(stderr, "DEBUG: Processing line: '%s'\n", line_ptr); - if (strcmp(line_ptr, "-----BEGIN OTP MESSAGE-----") == 0) { found_begin = 1; - fprintf(stderr, "DEBUG: Found BEGIN header\n"); } else if (strcmp(line_ptr, "-----END OTP MESSAGE-----") == 0) { - fprintf(stderr, "DEBUG: Found END header\n"); break; } else if (found_begin) { if (strncmp(line_ptr, "Pad-ChkSum: ", 12) == 0) { strncpy(stored_chksum, line_ptr + 12, 64); stored_chksum[64] = '\0'; - fprintf(stderr, "DEBUG: Found checksum: %.16s...\n", stored_chksum); } else if (strncmp(line_ptr, "Pad-Offset: ", 12) == 0) { pad_offset = strtoull(line_ptr + 12, NULL, 10); - fprintf(stderr, "DEBUG: Found offset: %lu\n", pad_offset); } else if (strlen(line_ptr) == 0) { in_data_section = 1; - fprintf(stderr, "DEBUG: Entering data section\n"); } else if (in_data_section) { strncat(base64_data, line_ptr, sizeof(base64_data) - strlen(base64_data) - 1); - fprintf(stderr, "DEBUG: Added data line: %s\n", line_ptr); } else if (strncmp(line_ptr, "Version:", 8) != 0 && strncmp(line_ptr, "Pad-", 4) != 0) { // This might be base64 data without a blank line separator strncat(base64_data, line_ptr, sizeof(base64_data) - strlen(base64_data) - 1); - fprintf(stderr, "DEBUG: Added potential data line: %s\n", line_ptr); } } line_ptr = strtok(NULL, "\n"); } free(message_copy); - fprintf(stderr, "DEBUG: Parsing complete. found_begin=%d, base64_data='%s'\n", found_begin, base64_data); - if (!found_begin) { fprintf(stderr, "Error: Invalid message format - missing BEGIN header\n"); return 1; @@ -1750,8 +1733,9 @@ int decrypt_text_silent(const char* pad_identifier, const char* encrypted_messag } plaintext[ciphertext_len] = '\0'; - // Output only the decrypted text - no extra messages - printf("%s", plaintext); + // Output only the decrypted text with newline and flush + printf("%s\n", plaintext); + fflush(stdout); // Cleanup free(ciphertext);