Compare commits
No commits in common. "17a73d9157d09dac59680d4bf853997152c4c94a" and "d3aa932bdcd834744efebe03d2c7a2f4c6855e51" have entirely different histories.
17a73d9157
...
d3aa932bdc
@ -104,20 +104,15 @@ why2_input_flags why2_get_flags(void); //RETURNS USED FLAGS
|
||||
why2_output_flags why2_no_output(enum WHY2_EXIT_CODES exit_code); //SAME AS why2_get_default_flags() BUT FOR why2_output_flags
|
||||
why2_encryption_operation_cb why2_get_encryption_operation(void); //RETURNS FUNCTION WHICH IS USED FOR ENCRYPTION & DECRYPTION
|
||||
why2_bool why2_get_flags_changed(void);
|
||||
why2_bool why2_get_padding_changed(void);
|
||||
char *why2_get_memory_identifier(void); //RETURNS STRING USED IN LINKED LIST (IN memory.c) FOR IDENTIFYING NODES WHEN RUNNING GARBAGE COLLECTOR
|
||||
char *why2_get_default_memory_identifier(void);
|
||||
|
||||
//SETTERS
|
||||
void why2_set_encryption_separator(char encryption_separator_new);
|
||||
void why2_set_key_length(int keyLengthNew);
|
||||
void why2_set_flags(why2_input_flags new_flags); //.... whatcha think?
|
||||
void __why2_set_flags_anon(why2_input_flags new_flags); //DO NOT CHANGE flags_changed ON USAGE
|
||||
void why2_set_flags(why2_input_flags newFlags); //.... whatcha think?
|
||||
void why2_set_encryption_operation(why2_encryption_operation_cb newEncryptionOperation); //are you that dumb?
|
||||
void why2_set_memory_identifier(char *new_memory_identifier);
|
||||
void why2_set_padding(unsigned long padding); //SET PADDING RATE WITHOUT REWRITING INPUT FLAGS
|
||||
void __why2_set_padding_anon(unsigned long padding);
|
||||
|
||||
void why2_reset_memory_identifier(void); //hmmm, what could reset mean.... huh
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -33,10 +33,9 @@ int encryptionOperation(int text, int encryptedText);
|
||||
//VARIABLES
|
||||
char encryption_separator = '.'; //NOPE > DO NOT TOUCH THIS, USE why2_set_encryption_separator instead <
|
||||
unsigned long keyLength = 50; //LENGTH OF KEY > DO NOT TOUCH THIS, USE why2_set_key_length instead <
|
||||
why2_input_flags used_flags = DEFAULT_FLAGS; //IT IS CALLED used_flags CUZ flags CAUSED SOME FUCKING MEMORY PROBLEMS
|
||||
why2_input_flags flagsAllah = DEFAULT_FLAGS; //IT IS CALLED flagsAllah CUZ flags CAUSED SOME FUCKING MEMORY PROBLEMS
|
||||
why2_encryption_operation_cb encryptionOperation_cb = encryptionOperation;
|
||||
why2_bool flags_changed = 0; //CHANGES TO 1 WHEN U USE why2_set_flags
|
||||
why2_bool padding_changed = 0; //SAME AS flags_changed BUT FOR PADDING
|
||||
why2_bool flagsChanged = 0; //CHANGES TO 1 WHEN U USE why2_set_flags
|
||||
char *memory_identifier = DEFAULT_MEMORY_IDENTIFIER;
|
||||
|
||||
why2_list_t identifier_list = WHY2_LIST_EMPTY;
|
||||
@ -69,7 +68,7 @@ why2_input_flags why2_get_default_flags(void)
|
||||
|
||||
why2_input_flags why2_get_flags(void)
|
||||
{
|
||||
return used_flags;
|
||||
return flagsAllah;
|
||||
}
|
||||
|
||||
why2_output_flags why2_no_output(enum WHY2_EXIT_CODES exit_code)
|
||||
@ -94,12 +93,7 @@ why2_encryption_operation_cb why2_get_encryption_operation(void)
|
||||
|
||||
why2_bool why2_get_flags_changed(void)
|
||||
{
|
||||
return flags_changed;
|
||||
}
|
||||
|
||||
why2_bool why2_get_padding_changed(void)
|
||||
{
|
||||
return padding_changed;
|
||||
return flagsChanged;
|
||||
}
|
||||
|
||||
char *why2_get_memory_identifier(void)
|
||||
@ -132,20 +126,11 @@ void why2_set_key_length(int keyLengthNew)
|
||||
keyLength = keyLengthNew;
|
||||
}
|
||||
|
||||
void why2_set_flags(why2_input_flags new_flags)
|
||||
void why2_set_flags(why2_input_flags newFlags)
|
||||
{
|
||||
__why2_set_flags_anon(new_flags);
|
||||
flagsAllah = newFlags;
|
||||
|
||||
if (!flags_changed)
|
||||
{
|
||||
flags_changed = 1;
|
||||
padding_changed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void __why2_set_flags_anon(why2_input_flags new_flags)
|
||||
{
|
||||
used_flags = new_flags;
|
||||
if (!flagsChanged) flagsChanged = 1;
|
||||
}
|
||||
|
||||
void why2_set_encryption_operation(why2_encryption_operation_cb newEncryptionOperation)
|
||||
@ -160,17 +145,6 @@ void why2_set_memory_identifier(char *new_memory_identifier)
|
||||
memory_identifier = new_memory_identifier;
|
||||
}
|
||||
|
||||
void why2_set_padding(unsigned long padding)
|
||||
{
|
||||
__why2_set_padding_anon(padding);
|
||||
if (!padding_changed) padding_changed = 1;
|
||||
}
|
||||
|
||||
void __why2_set_padding_anon(unsigned long padding)
|
||||
{
|
||||
used_flags.padding = padding;
|
||||
}
|
||||
|
||||
void why2_reset_memory_identifier(void)
|
||||
{
|
||||
why2_list_remove_back(&identifier_list);
|
||||
|
@ -29,9 +29,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <why2/logger/flags.h>
|
||||
#include <why2/logger/utils.h>
|
||||
|
||||
#include <why2/crypto.h>
|
||||
#include <why2/encrypter.h>
|
||||
#include <why2/flags.h>
|
||||
#include <why2/memory.h>
|
||||
#include <why2/misc.h>
|
||||
|
||||
@ -96,9 +94,6 @@ why2_log_file why2_init_logger(char *directoryPath)
|
||||
}
|
||||
}
|
||||
|
||||
//SET ENCRYPTER FLAGS
|
||||
if (!why2_get_flags_changed()) __why2_set_flags_anon((why2_input_flags) { 0, 1, 0, WHY2_v4, WHY2_OUTPUT_TEXT, 64 });
|
||||
|
||||
//DEALLOCATION
|
||||
why2_deallocate(dateBuffer);
|
||||
why2_deallocate(latestBuffer);
|
||||
@ -126,7 +121,7 @@ void why2_write_log(int loggerFile, char *logMessage)
|
||||
char *logMessageUsed = why2_strdup(logMessage);
|
||||
for (int i = 0; i < (int) strlen(logMessageUsed); i++)
|
||||
{
|
||||
if (logMessageUsed[i] == '\n') logMessageUsed[i] = ' ';
|
||||
if (logMessageUsed[i] == '\n') logMessageUsed[i] = '\0';
|
||||
}
|
||||
|
||||
//VARIABLES
|
||||
@ -136,7 +131,8 @@ void why2_write_log(int loggerFile, char *logMessage)
|
||||
struct tm tm = *localtime(&timeL);
|
||||
why2_log_flags flags = why2_get_log_flags();
|
||||
|
||||
if (!why2_get_padding_changed()) __why2_set_padding_anon(WHY2_RECOMMENDED_PADDING_RATE(strlen(logMessageUsed)));
|
||||
//SET ENCRYPTER FLAGS
|
||||
if (!why2_get_flags_changed()) why2_set_flags((why2_input_flags) { 0, 1, 0, WHY2_v4, WHY2_OUTPUT_TEXT, 63 });
|
||||
|
||||
if (flags.key != NULL) //ENCRYPT TEXT IF KEY WAS CHANGED
|
||||
{
|
||||
|
@ -107,17 +107,6 @@ why2_decrypted_output why2_decrypt_logger(why2_log_file logger)
|
||||
|
||||
for (int i = 0; i < lines; i++) //DECRYPT content
|
||||
{
|
||||
if (!why2_get_padding_changed())
|
||||
{
|
||||
printf("A\n");
|
||||
unsigned long length_buffer = 1;
|
||||
for (unsigned long j = 0; j < strlen(content[i]); j++)
|
||||
{
|
||||
if (content[i][j] == why2_get_encryption_separator()) length_buffer++;
|
||||
}
|
||||
__why2_set_padding_anon(length_buffer / 4);
|
||||
}
|
||||
|
||||
outputBuffer = why2_decrypt_text(content[i], why2_get_log_flags().key); //DECRYPT
|
||||
|
||||
contentDecrypted[i] = why2_strdup(outputBuffer.output_text); //COPY
|
||||
|
Loading…
x
Reference in New Issue
Block a user