Compare commits
8 Commits
d3aa932bdc
...
17a73d9157
Author | SHA1 | Date | |
---|---|---|---|
17a73d9157 | |||
520f8bce34 | |||
9e5016feb7 | |||
59d6252fe3 | |||
64f54fadce | |||
4451b848f7 | |||
917b466b11 | |||
0fe3f47752 |
@ -104,15 +104,20 @@ 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_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_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_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_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);
|
char *why2_get_default_memory_identifier(void);
|
||||||
|
|
||||||
//SETTERS
|
//SETTERS
|
||||||
void why2_set_encryption_separator(char encryption_separator_new);
|
void why2_set_encryption_separator(char encryption_separator_new);
|
||||||
void why2_set_key_length(int keyLengthNew);
|
void why2_set_key_length(int keyLengthNew);
|
||||||
void why2_set_flags(why2_input_flags newFlags); //.... whatcha think?
|
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_encryption_operation(why2_encryption_operation_cb newEncryptionOperation); //are you that dumb?
|
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_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
|
void why2_reset_memory_identifier(void); //hmmm, what could reset mean.... huh
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -33,9 +33,10 @@ int encryptionOperation(int text, int encryptedText);
|
|||||||
//VARIABLES
|
//VARIABLES
|
||||||
char encryption_separator = '.'; //NOPE > DO NOT TOUCH THIS, USE why2_set_encryption_separator instead <
|
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 <
|
unsigned long keyLength = 50; //LENGTH OF KEY > DO NOT TOUCH THIS, USE why2_set_key_length instead <
|
||||||
why2_input_flags flagsAllah = DEFAULT_FLAGS; //IT IS CALLED flagsAllah CUZ flags CAUSED SOME FUCKING MEMORY PROBLEMS
|
why2_input_flags used_flags = DEFAULT_FLAGS; //IT IS CALLED used_flags CUZ flags CAUSED SOME FUCKING MEMORY PROBLEMS
|
||||||
why2_encryption_operation_cb encryptionOperation_cb = encryptionOperation;
|
why2_encryption_operation_cb encryptionOperation_cb = encryptionOperation;
|
||||||
why2_bool flagsChanged = 0; //CHANGES TO 1 WHEN U USE why2_set_flags
|
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
|
||||||
char *memory_identifier = DEFAULT_MEMORY_IDENTIFIER;
|
char *memory_identifier = DEFAULT_MEMORY_IDENTIFIER;
|
||||||
|
|
||||||
why2_list_t identifier_list = WHY2_LIST_EMPTY;
|
why2_list_t identifier_list = WHY2_LIST_EMPTY;
|
||||||
@ -68,7 +69,7 @@ why2_input_flags why2_get_default_flags(void)
|
|||||||
|
|
||||||
why2_input_flags why2_get_flags(void)
|
why2_input_flags why2_get_flags(void)
|
||||||
{
|
{
|
||||||
return flagsAllah;
|
return used_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
why2_output_flags why2_no_output(enum WHY2_EXIT_CODES exit_code)
|
why2_output_flags why2_no_output(enum WHY2_EXIT_CODES exit_code)
|
||||||
@ -93,7 +94,12 @@ why2_encryption_operation_cb why2_get_encryption_operation(void)
|
|||||||
|
|
||||||
why2_bool why2_get_flags_changed(void)
|
why2_bool why2_get_flags_changed(void)
|
||||||
{
|
{
|
||||||
return flagsChanged;
|
return flags_changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
why2_bool why2_get_padding_changed(void)
|
||||||
|
{
|
||||||
|
return padding_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *why2_get_memory_identifier(void)
|
char *why2_get_memory_identifier(void)
|
||||||
@ -126,11 +132,20 @@ void why2_set_key_length(int keyLengthNew)
|
|||||||
keyLength = keyLengthNew;
|
keyLength = keyLengthNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
void why2_set_flags(why2_input_flags newFlags)
|
void why2_set_flags(why2_input_flags new_flags)
|
||||||
{
|
{
|
||||||
flagsAllah = newFlags;
|
__why2_set_flags_anon(new_flags);
|
||||||
|
|
||||||
if (!flagsChanged) flagsChanged = 1;
|
if (!flags_changed)
|
||||||
|
{
|
||||||
|
flags_changed = 1;
|
||||||
|
padding_changed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void __why2_set_flags_anon(why2_input_flags new_flags)
|
||||||
|
{
|
||||||
|
used_flags = new_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void why2_set_encryption_operation(why2_encryption_operation_cb newEncryptionOperation)
|
void why2_set_encryption_operation(why2_encryption_operation_cb newEncryptionOperation)
|
||||||
@ -145,6 +160,17 @@ void why2_set_memory_identifier(char *new_memory_identifier)
|
|||||||
memory_identifier = 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)
|
void why2_reset_memory_identifier(void)
|
||||||
{
|
{
|
||||||
why2_list_remove_back(&identifier_list);
|
why2_list_remove_back(&identifier_list);
|
||||||
|
@ -29,7 +29,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
#include <why2/logger/flags.h>
|
#include <why2/logger/flags.h>
|
||||||
#include <why2/logger/utils.h>
|
#include <why2/logger/utils.h>
|
||||||
|
|
||||||
|
#include <why2/crypto.h>
|
||||||
#include <why2/encrypter.h>
|
#include <why2/encrypter.h>
|
||||||
|
#include <why2/flags.h>
|
||||||
#include <why2/memory.h>
|
#include <why2/memory.h>
|
||||||
#include <why2/misc.h>
|
#include <why2/misc.h>
|
||||||
|
|
||||||
@ -94,6 +96,9 @@ 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
|
//DEALLOCATION
|
||||||
why2_deallocate(dateBuffer);
|
why2_deallocate(dateBuffer);
|
||||||
why2_deallocate(latestBuffer);
|
why2_deallocate(latestBuffer);
|
||||||
@ -121,7 +126,7 @@ void why2_write_log(int loggerFile, char *logMessage)
|
|||||||
char *logMessageUsed = why2_strdup(logMessage);
|
char *logMessageUsed = why2_strdup(logMessage);
|
||||||
for (int i = 0; i < (int) strlen(logMessageUsed); i++)
|
for (int i = 0; i < (int) strlen(logMessageUsed); i++)
|
||||||
{
|
{
|
||||||
if (logMessageUsed[i] == '\n') logMessageUsed[i] = '\0';
|
if (logMessageUsed[i] == '\n') logMessageUsed[i] = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
//VARIABLES
|
//VARIABLES
|
||||||
@ -131,8 +136,7 @@ void why2_write_log(int loggerFile, char *logMessage)
|
|||||||
struct tm tm = *localtime(&timeL);
|
struct tm tm = *localtime(&timeL);
|
||||||
why2_log_flags flags = why2_get_log_flags();
|
why2_log_flags flags = why2_get_log_flags();
|
||||||
|
|
||||||
//SET ENCRYPTER FLAGS
|
if (!why2_get_padding_changed()) __why2_set_padding_anon(WHY2_RECOMMENDED_PADDING_RATE(strlen(logMessageUsed)));
|
||||||
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
|
if (flags.key != NULL) //ENCRYPT TEXT IF KEY WAS CHANGED
|
||||||
{
|
{
|
||||||
|
@ -107,6 +107,17 @@ why2_decrypted_output why2_decrypt_logger(why2_log_file logger)
|
|||||||
|
|
||||||
for (int i = 0; i < lines; i++) //DECRYPT content
|
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
|
outputBuffer = why2_decrypt_text(content[i], why2_get_log_flags().key); //DECRYPT
|
||||||
|
|
||||||
contentDecrypted[i] = why2_strdup(outputBuffer.output_text); //COPY
|
contentDecrypted[i] = why2_strdup(outputBuffer.output_text); //COPY
|
||||||
|
Loading…
x
Reference in New Issue
Block a user