Version v0.2.44 - cleaned up unused code - removed ensure_files_directory, xor_checksum_256, generate_pad, and get_user_choice functions and prototypes

This commit is contained in:
2025-08-13 13:46:52 -04:00
parent 864c0356da
commit aff8bea0a2
2 changed files with 1 additions and 34 deletions

1
files/o2.txt Normal file
View File

@@ -0,0 +1 @@
Hello, this is a test file for encryption!

34
otp.c
View File

@@ -73,7 +73,6 @@ void simple_entropy_mix(unsigned char* urandom_buffer, size_t buffer_size,
// Directory management // Directory management
int ensure_pads_directory(void); int ensure_pads_directory(void);
int ensure_files_directory(void);
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);
const char* get_files_directory(void); const char* get_files_directory(void);
void get_default_file_path(const char* filename, char* result_path, size_t result_size); void get_default_file_path(const char* filename, char* result_path, size_t result_size);
@@ -83,14 +82,12 @@ uint64_t parse_size_string(const char* size_str);
char* find_pad_by_prefix(const char* prefix); char* find_pad_by_prefix(const char* prefix);
int list_available_pads(void); int list_available_pads(void);
int show_pad_info(const char* chksum); int show_pad_info(const char* chksum);
int get_user_choice(int min, int max);
void show_progress(uint64_t current, uint64_t total, time_t start_time); void show_progress(uint64_t current, uint64_t total, time_t start_time);
// File operations // File operations
int read_state_offset(const char* pad_chksum, uint64_t* offset); 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);
int calculate_checksum(const char* filename, char* checksum_hex); int calculate_checksum(const char* filename, char* checksum_hex);
void xor_checksum_256(const unsigned char* data, size_t len, unsigned char checksum[32]);
char* custom_base64_encode(const unsigned char* input, int length); char* custom_base64_encode(const unsigned char* input, int length);
unsigned char* custom_base64_decode(const char* input, int* output_length); unsigned char* custom_base64_decode(const char* input, int* output_length);
@@ -852,20 +849,6 @@ int show_pad_info(const char* chksum) {
return 0; return 0;
} }
int get_user_choice(int min, int max) {
char input[64];
int choice;
while (1) {
if (fgets(input, sizeof(input), stdin)) {
choice = atoi(input);
if (choice >= min && choice <= max) {
return choice;
}
}
printf("Please enter a number between %d and %d: ", min, max);
}
}
void show_progress(uint64_t current, uint64_t total, time_t start_time) { void show_progress(uint64_t current, uint64_t total, time_t start_time) {
time_t now = time(NULL); time_t now = time(NULL);
@@ -2282,15 +2265,6 @@ int ensure_pads_directory(void) {
return 0; return 0;
} }
int ensure_files_directory(void) {
struct stat st = {0};
if (stat(FILES_DIR, &st) == -1) {
if (mkdir(FILES_DIR, 0755) != 0) {
return 1;
}
}
return 0;
}
const char* get_files_directory(void) { const char* get_files_directory(void) {
struct stat st = {0}; struct stat st = {0};
@@ -2320,14 +2294,6 @@ void get_pad_path(const char* chksum, char* pad_path, char* state_path) {
} }
// Custom XOR checksum function
void xor_checksum_256(const unsigned char* data, size_t len, unsigned char checksum[32]) {
memset(checksum, 0, 32);
for (size_t i = 0; i < len; i++) {
unsigned char bucket = i % 32;
checksum[bucket] ^= data[i] ^ ((i >> 8) & 0xFF) ^ ((i >> 16) & 0xFF) ^ ((i >> 24) & 0xFF);
}
}
// Custom base64 encode function // Custom base64 encode function
char* custom_base64_encode(const unsigned char* input, int length) { char* custom_base64_encode(const unsigned char* input, int length) {