created code for decrypting logger
send part of this update tho
This commit is contained in:
parent
000021b9a2
commit
6620382d4e
@ -23,6 +23,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <why2/decrypter.h>
|
||||||
|
#include <why2/flags.h>
|
||||||
|
#include <why2/misc.h>
|
||||||
|
|
||||||
#include <why2/logger/flags.h>
|
#include <why2/logger/flags.h>
|
||||||
|
|
||||||
void deallocateLogger(logFile logger)
|
void deallocateLogger(logFile logger)
|
||||||
@ -47,8 +51,10 @@ void decryptLogger(logFile logger) //TODO: Fix valgrind issues
|
|||||||
{
|
{
|
||||||
|
|
||||||
FILE *file = fdopen(logger.file, "r"); //OPEN logFile AS FILE POINTER
|
FILE *file = fdopen(logger.file, "r"); //OPEN logFile AS FILE POINTER
|
||||||
|
outputFlags outputBuffer;
|
||||||
char *rawContent;
|
char *rawContent;
|
||||||
char **linesContent;
|
char **linesContent;
|
||||||
|
char **linesContentDecrypted;
|
||||||
int rawContentLength;
|
int rawContentLength;
|
||||||
int lines = 0;
|
int lines = 0;
|
||||||
int buffer = 0;
|
int buffer = 0;
|
||||||
@ -73,7 +79,9 @@ void decryptLogger(logFile logger) //TODO: Fix valgrind issues
|
|||||||
if (rawContent[i] == '\n') lines++;
|
if (rawContent[i] == '\n') lines++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ALLOCATE SPLIT & SPLIT DECRYPTED BUFFERS
|
||||||
linesContent = malloc(lines + 1);
|
linesContent = malloc(lines + 1);
|
||||||
|
linesContentDecrypted = malloc(lines + 1);
|
||||||
|
|
||||||
for (int i = 0; i < rawContentLength; i++) //LOAD/SPIT rawContent INTO linesContent
|
for (int i = 0; i < rawContentLength; i++) //LOAD/SPIT rawContent INTO linesContent
|
||||||
{
|
{
|
||||||
@ -108,13 +116,29 @@ void decryptLogger(logFile logger) //TODO: Fix valgrind issues
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Decrypt
|
//TODO: Decrypt
|
||||||
|
for (int i = 0; i < buffer3; i++)
|
||||||
|
{
|
||||||
|
outputBuffer = decryptText(linesContent[i], getLogFlags().key);
|
||||||
|
|
||||||
|
linesContentDecrypted[i] = strdup(outputBuffer.outputText);
|
||||||
|
|
||||||
|
deallocateOutput(outputBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < buffer3; i++)
|
for (int i = 0; i < buffer3; i++)
|
||||||
{
|
{
|
||||||
free(linesContent[i]);
|
printf("%s\n", linesContentDecrypted[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//DEALLOCATE EACH linesContent & linesContentDecrypted INDEX
|
||||||
|
for (int i = 0; i < buffer3; i++)
|
||||||
|
{
|
||||||
|
free(linesContent[i]);
|
||||||
|
free(linesContentDecrypted[i]); //TODO: Remove
|
||||||
|
}
|
||||||
|
|
||||||
free(linesContent);
|
free(linesContent);
|
||||||
|
free(linesContentDecrypted); //TODO: Remove
|
||||||
|
|
||||||
free(rawContent);
|
free(rawContent);
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user