Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f979789c11 | |||
| 498d7d31c4 | |||
| e58f05619e |
72
otp.c
72
otp.c
@@ -132,41 +132,41 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int interactive_mode(void) {
|
int interactive_mode(void) {
|
||||||
// printf("\n\n\n\n=== OTP Cipher %s ===\n\n", get_version());
|
char input[10];
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
show_main_menu();
|
show_main_menu();
|
||||||
char input[10];
|
|
||||||
if (fgets(input, sizeof(input), stdin)) {
|
if (!fgets(input, sizeof(input), stdin)) {
|
||||||
char choice = toupper(input[0]);
|
printf("Goodbye!\n");
|
||||||
|
break;
|
||||||
switch (choice) {
|
}
|
||||||
case 'T':
|
|
||||||
handle_text_encrypt();
|
char choice = toupper(input[0]);
|
||||||
break;
|
|
||||||
case 'F':
|
switch (choice) {
|
||||||
handle_file_encrypt();
|
case 'T':
|
||||||
break;
|
handle_text_encrypt();
|
||||||
case 'D':
|
break;
|
||||||
handle_decrypt_menu();
|
case 'F':
|
||||||
break;
|
handle_file_encrypt();
|
||||||
case 'P':
|
break;
|
||||||
handle_pads_menu();
|
case 'D':
|
||||||
break;
|
handle_decrypt_menu();
|
||||||
case 'X':
|
break;
|
||||||
case 'Q':
|
case 'P':
|
||||||
printf("Goodbye!\n");
|
handle_pads_menu();
|
||||||
return 0;
|
break;
|
||||||
default:
|
case 'X':
|
||||||
printf("Invalid option. Please select T, F, D, P, or X.\n");
|
printf("Goodbye!\n");
|
||||||
continue;
|
return 0;
|
||||||
}
|
default:
|
||||||
} else {
|
printf("Invalid choice. Please try again.\n");
|
||||||
printf("Error reading input. Please try again.\n");
|
break;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
printf("\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int command_line_mode(int argc, char* argv[]) {
|
int command_line_mode(int argc, char* argv[]) {
|
||||||
@@ -767,7 +767,7 @@ int list_available_pads(void) {
|
|||||||
chksum[64] = '\0';
|
chksum[64] = '\0';
|
||||||
|
|
||||||
// Get pad file size
|
// Get pad file size
|
||||||
char full_path[300]; // Increased buffer size to accommodate longer paths
|
char full_path[1024]; // Increased buffer size to accommodate longer paths
|
||||||
snprintf(full_path, sizeof(full_path), "%s/%s", current_pads_dir, entry->d_name);
|
snprintf(full_path, sizeof(full_path), "%s/%s", current_pads_dir, entry->d_name);
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(full_path, &st) == 0) {
|
if (stat(full_path, &st) == 0) {
|
||||||
@@ -2095,7 +2095,7 @@ int decrypt_ascii_file(const char* input_file, const char* output_file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int read_state_offset(const char* pad_chksum, uint64_t* offset) {
|
int read_state_offset(const char* pad_chksum, uint64_t* offset) {
|
||||||
char state_filename[MAX_HASH_LENGTH + 20];
|
char state_filename[1024];
|
||||||
snprintf(state_filename, sizeof(state_filename), "%s/%s.state", current_pads_dir, pad_chksum);
|
snprintf(state_filename, sizeof(state_filename), "%s/%s.state", current_pads_dir, pad_chksum);
|
||||||
|
|
||||||
FILE* state_file = fopen(state_filename, "rb");
|
FILE* state_file = fopen(state_filename, "rb");
|
||||||
@@ -2115,7 +2115,7 @@ int read_state_offset(const char* pad_chksum, uint64_t* offset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int write_state_offset(const char* pad_chksum, uint64_t offset) {
|
int write_state_offset(const char* pad_chksum, uint64_t offset) {
|
||||||
char state_filename[MAX_HASH_LENGTH + 20];
|
char state_filename[1024];
|
||||||
snprintf(state_filename, sizeof(state_filename), "%s/%s.state", current_pads_dir, pad_chksum);
|
snprintf(state_filename, sizeof(state_filename), "%s/%s.state", current_pads_dir, pad_chksum);
|
||||||
|
|
||||||
FILE* state_file = fopen(state_filename, "wb");
|
FILE* state_file = fopen(state_filename, "wb");
|
||||||
@@ -2289,8 +2289,8 @@ void get_default_file_path(const char* filename, char* result_path, size_t resul
|
|||||||
}
|
}
|
||||||
|
|
||||||
void get_pad_path(const char* chksum, char* pad_path, char* state_path) {
|
void get_pad_path(const char* chksum, char* pad_path, char* state_path) {
|
||||||
snprintf(pad_path, MAX_HASH_LENGTH + 20, "%s/%s.pad", current_pads_dir, chksum);
|
snprintf(pad_path, 1024, "%s/%s.pad", current_pads_dir, chksum);
|
||||||
snprintf(state_path, MAX_HASH_LENGTH + 20, "%s/%s.state", current_pads_dir, chksum);
|
snprintf(state_path, 1024, "%s/%s.state", current_pads_dir, chksum);
|
||||||
}
|
}
|
||||||
|
|
||||||
// OTP thumb drive detection function implementation
|
// OTP thumb drive detection function implementation
|
||||||
@@ -3198,7 +3198,7 @@ void get_directory_display(const char* file_path, char* result, size_t result_si
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Current working directory
|
// Current working directory
|
||||||
if (strcmp(dir_path, ".") == 0 || strcmp(dir_path, PADS_DIR) == 0) {
|
if (strcmp(dir_path, ".") == 0 || strcmp(dir_path, current_pads_dir) == 0) {
|
||||||
strncpy(result, "pads", result_size - 1);
|
strncpy(result, "pads", result_size - 1);
|
||||||
result[result_size - 1] = '\0';
|
result[result_size - 1] = '\0';
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user