diff --git a/otp-arm64 b/otp-arm64 index 9458558..d4ee11e 100755 Binary files a/otp-arm64 and b/otp-arm64 differ diff --git a/otp-x86_64 b/otp-x86_64 index 9204611..6e7a9ca 100755 Binary files a/otp-x86_64 and b/otp-x86_64 differ diff --git a/otp.c b/otp.c index e5953a6..ac2b16d 100644 --- a/otp.c +++ b/otp.c @@ -78,10 +78,28 @@ void init_terminal_dimensions(void) { // If ioctl fails, keep the default values (80x24) } -// Print centered header with = padding -void print_centered_header(const char* text) { +// Print centered header with = padding, screen clearing, and optional pause +void print_centered_header(const char* text, int pause_before_clear) { if (!text) return; + // Phase 1: Pause if requested + if (pause_before_clear) { + printf("\nPress Enter to continue..."); + fflush(stdout); + + // Wait for Enter key + int c; + while ((c = getchar()) != '\n' && c != EOF) { + // Consume any extra characters until newline + } + } + + // Phase 2: Clear screen using terminal height + for (int i = 0; i < terminal_height; i++) { + printf("\n"); + } + + // Phase 3: Display centered header (existing logic) int text_len = strlen(text); int available_width = terminal_width; @@ -387,7 +405,7 @@ int interactive_mode(void) { void show_main_menu(void) { printf("\n"); - print_centered_header("Main Menu - OTP v0.3.10"); + print_centered_header("Main Menu - OTP v0.3.11", 0); printf("\n"); printf(" \033[4mT\033[0mext encrypt\n"); //TEXT ENCRYPT @@ -400,7 +418,7 @@ void show_main_menu(void) { int handle_generate_menu(void) { printf("\n"); - print_centered_header("Generate New Pad"); + print_centered_header("Generate New Pad", 0); printf("Enter pad size (examples: 1GB, 5TB, 512MB, 2048): "); char size_input[64]; @@ -426,7 +444,7 @@ int handle_generate_menu(void) { int handle_encrypt_menu(void) { printf("\n"); - print_centered_header("Encrypt Data"); + print_centered_header("Encrypt Data", 0); printf("Available pads:\n"); char* selected = select_pad_interactive("Available pads:", "Select pad (or press Enter to continue)", PAD_FILTER_ALL, 0); @@ -568,7 +586,7 @@ int handle_encrypt_menu(void) { int handle_decrypt_menu(void) { printf("\n"); - print_centered_header("Smart Decrypt"); + print_centered_header("Smart Decrypt", 0); printf("Enter encrypted data (paste ASCII armor), file path, or press Enter to browse files:\n"); char input_line[MAX_LINE_LENGTH]; @@ -802,7 +820,7 @@ int show_pad_info(const char* chksum) { uint64_t used_bytes; read_state_offset(chksum, &used_bytes); - print_centered_header("Pad Information"); + print_centered_header("Pad Information", 0); printf("ChkSum: %s\n", chksum); printf("File: %s\n", pad_filename); @@ -977,6 +995,9 @@ int generate_pad(uint64_t size_bytes, int display_progress) { printf("Pad file set to read-only\n"); printf("Use 'Add entropy' in Pads menu to enhance randomness.\n"); + // Pause before returning to menu to let user see the success message + print_centered_header("Pad Generation Complete", 1); + return 0; } @@ -1117,6 +1138,9 @@ int add_entropy_to_pad(const char* pad_chksum, const unsigned char* entropy_data printf(" Old checksum: %.16s...\n", pad_chksum); printf(" New checksum: %.16s...\n", new_chksum); printf("✓ Pad files renamed to new checksum\n"); + + // Pause before returning to menu to let user see the success message + print_centered_header("Entropy Addition Complete", 1); } else if (checksum_result == 2) { printf("ℹ Checksum unchanged (unusual but not an error)\n"); } else { @@ -1600,6 +1624,9 @@ int encrypt_file(const char* pad_identifier, const char* input_file, const char* printf("Format: Binary (.otp)\n"); } + // Pause before returning to menu to let user see the success message + print_centered_header("File Encryption Complete", 1); + // Cleanup free(encrypted_data); free(pad_chksum); @@ -1768,6 +1795,9 @@ int decrypt_binary_file(FILE* input_fp, const char* output_file) { printf("File decrypted successfully: %s\n", output_file); printf("Restored permissions and metadata\n"); + // Pause before returning to menu to let user see the success message + print_centered_header("File Decryption Complete", 1); + // Cleanup free(encrypted_data); free(pad_data); @@ -3095,6 +3125,9 @@ int collect_truerng_entropy_streaming(const char* pad_chksum, size_t total_bytes printf("✓ Pad integrity maintained\n"); printf("✓ Entropy distributed across entire pad\n"); printf("✓ Pad restored to read-only mode\n"); + + // Pause before returning to menu to let user see the success message + print_centered_header("TrueRNG Enhancement Complete", 1); } return 0; // Success @@ -3104,7 +3137,7 @@ int collect_truerng_entropy_streaming(const char* pad_chksum, size_t total_bytes int collect_dice_entropy(unsigned char* entropy_buffer, size_t target_bytes, size_t* collected_bytes, int display_progress) { if (display_progress) { - print_centered_header("Dice Entropy Collection"); + print_centered_header("Dice Entropy Collection", 0); printf("Enter dice rolls as sequences of digits 1-6.\n"); printf("Target: %zu bytes (%zu dice rolls needed)\n", target_bytes, target_bytes * 4); printf("Press Enter after each sequence, or 'done' when finished.\n\n"); @@ -3792,7 +3825,7 @@ int generate_ascii_armor(const char* chksum, uint64_t offset, const unsigned cha strcpy(*ascii_output, "-----BEGIN OTP MESSAGE-----\n"); char temp_line[256]; - snprintf(temp_line, sizeof(temp_line), "Version: v0.3.10\n"); + snprintf(temp_line, sizeof(temp_line), "Version: v0.3.11\n"); strcat(*ascii_output, temp_line); snprintf(temp_line, sizeof(temp_line), "Pad-ChkSum: %s\n", chksum); @@ -4457,7 +4490,7 @@ int launch_file_manager(const char* start_directory, char* selected_file, size_t int handle_text_encrypt(void) { printf("\n"); - print_centered_header("Text Encrypt"); + print_centered_header("Text Encrypt", 0); // Launch text editor directly char text_buffer[MAX_INPUT_SIZE]; @@ -4487,7 +4520,7 @@ int handle_text_encrypt(void) { int handle_file_encrypt(void) { printf("\n"); - print_centered_header("File Encrypt"); + print_centered_header("File Encrypt", 0); // Launch file manager directly char input_file[512]; @@ -4845,7 +4878,7 @@ char* select_pad_interactive(const char* title, const char* prompt, pad_filter_t int handle_pads_menu(void) { printf("\n"); - print_centered_header("Pad Management"); + print_centered_header("Pad Management", 0); // Get list of pads from current directory DIR* dir = opendir(current_pads_dir); @@ -5147,7 +5180,7 @@ int handle_add_entropy_to_pad(const char* pad_chksum) { char header_text[128]; snprintf(header_text, sizeof(header_text), "Add Entropy to Pad: %.16s...", pad_chksum); printf("\n"); - print_centered_header(header_text); + print_centered_header(header_text, 0); // Present entropy source selection menu with consistent formatting printf("Select entropy source:\n"); @@ -5281,8 +5314,9 @@ int handle_add_entropy_to_pad(const char* pad_chksum) { } printf("\n🎉 SUCCESS! Your entire pad now has enhanced randomness!\n"); - printf("Press Enter to continue..."); - getchar(); + + // Use enhanced pause mechanism instead of simple getchar + print_centered_header("Pad Enhancement Complete", 1); return 0; } @@ -5328,8 +5362,9 @@ int handle_add_entropy_to_pad(const char* pad_chksum) { } printf("\n🎉 SUCCESS! Your pad now has enhanced randomness!\n"); - printf("Press Enter to continue..."); - getchar(); + + // Use enhanced pause mechanism instead of simple getchar + print_centered_header("Entropy Enhancement Complete", 1); return 0; } @@ -5338,7 +5373,7 @@ int handle_verify_pad(const char* pad_chksum) { char header_text[128]; snprintf(header_text, sizeof(header_text), "Verify Pad Integrity: %.16s...", pad_chksum); printf("\n"); - print_centered_header(header_text); + print_centered_header(header_text, 0); // Construct pad file path char pad_path[1024]; @@ -5383,6 +5418,9 @@ int handle_verify_pad(const char* pad_chksum) { } printf("\n✅ This pad is safe to use for encryption.\n"); + + // Pause before returning to menu to let user see the verification results + print_centered_header("Pad Verification Complete", 1); return 0; } else { printf("❌ FAILURE: Pad integrity check failed!\n"); @@ -5400,7 +5438,7 @@ int handle_delete_pad(const char* pad_chksum) { char header_text[128]; snprintf(header_text, sizeof(header_text), "Delete Pad: %.16s...", pad_chksum); printf("\n"); - print_centered_header(header_text); + print_centered_header(header_text, 0); // Construct pad and state file paths char pad_path[1024]; @@ -5521,12 +5559,15 @@ int handle_delete_pad(const char* pad_chksum) { printf(" Checksum: %.16s...\n", pad_chksum); printf(" Both pad and state files have been removed\n"); + // Pause before returning to menu to let user see the success message + print_centered_header("Pad Deletion Complete", 1); + return 0; } void print_usage(const char* program_name) { - printf("OTP Cipher - One Time Pad Implementation v0.3.10\n"); + printf("OTP Cipher - One Time Pad Implementation v0.3.11\n"); printf("Built for testing entropy system\n"); printf("Usage:\n"); printf(" %s - Interactive mode\n", program_name); diff --git a/otp.h b/otp.h index 2600e5f..a1def2a 100644 --- a/otp.h +++ b/otp.h @@ -254,7 +254,7 @@ unsigned char* custom_base64_decode(const char* input, int* output_length); // Terminal dimension and UI functions void init_terminal_dimensions(void); -void print_centered_header(const char* text); +void print_centered_header(const char* text, int pause_before_clear); //////////////////////////////////////////////////////////////////////////////// // MENU SYSTEM FUNCTIONS