implemented inputFlags & outputFlags
This commit is contained in:
parent
60356033fa
commit
a11415b949
@ -1,6 +1,8 @@
|
|||||||
#ifndef WHY2_DECRYPTER_H
|
#ifndef WHY2_DECRYPTER_H
|
||||||
#define WHY2_DECRYPTER_H
|
#define WHY2_DECRYPTER_H
|
||||||
|
|
||||||
char *decryptText(char *text, char *key); //TEXT from WILL BE DECRYPTED WITH KEY AND RETURNED
|
#include <why2/flags.h>
|
||||||
|
|
||||||
|
outputFlags decryptText(char *text, char *key, inputFlags flags); //TEXT from WILL BE DECRYPTED WITH KEY AND RETURNED
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef WHY2_ENCRYPTER_H
|
#ifndef WHY2_ENCRYPTER_H
|
||||||
#define WHY2_ENCRYPTER_H
|
#define WHY2_ENCRYPTER_H
|
||||||
|
|
||||||
char *encryptText(char *text, char *keyNew); //TEXT from WILL BE ENCRYPTED WITH RANDOM PASSWORD [KEY] (WHICH WILL BE PRINTED OUT) AND RETURNED
|
#include <why2/flags.h>
|
||||||
|
|
||||||
|
outputFlags encryptText(char *text, char *keyNew, inputFlags flags); //TEXT from WILL BE ENCRYPTED WITH RANDOM PASSWORD [KEY] (WHICH WILL BE PRINTED OUT) AND RETURNED
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -23,17 +23,17 @@
|
|||||||
|
|
||||||
#define DEPRECATED __attribute__((deprecated))
|
#define DEPRECATED __attribute__((deprecated))
|
||||||
|
|
||||||
typedef struct inputFlag
|
typedef struct input
|
||||||
{
|
{
|
||||||
int skipCheck;
|
int skipCheck;
|
||||||
int noOutput;
|
int noOutput;
|
||||||
} inputFlags;
|
} inputFlags;
|
||||||
|
|
||||||
typedef struct outputFlag
|
typedef struct output
|
||||||
{
|
{
|
||||||
char *outputText;
|
char *outputText;
|
||||||
char *usedKey;
|
char *usedKey;
|
||||||
} *outputFlags;
|
} outputFlags;
|
||||||
|
|
||||||
//VARIABLES
|
//VARIABLES
|
||||||
static int keyLength = 50; //LENGTH OF KEY > DO NOT TOUCH THIS <
|
static int keyLength = 50; //LENGTH OF KEY > DO NOT TOUCH THIS <
|
||||||
|
@ -6,10 +6,13 @@
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
setNoOutput(1);
|
inputFlags flags =
|
||||||
setSkipCheck(1);
|
{
|
||||||
|
1, //SKIP CHECK
|
||||||
|
1 //NO OUTPUT
|
||||||
|
};
|
||||||
|
|
||||||
char *encryptedText = encryptText(TEXT_TO_ENCRYPT, NULL);
|
outputFlags encryptedText = encryptText(TEXT_TO_ENCRYPT, NULL, flags);
|
||||||
|
|
||||||
printf
|
printf
|
||||||
(
|
(
|
||||||
@ -21,9 +24,8 @@ int main(void)
|
|||||||
"If you'd like to know more about WHY2 Encryption System, please visit: https://github.com/ENGO150/WHY2/wiki \n"
|
"If you'd like to know more about WHY2 Encryption System, please visit: https://github.com/ENGO150/WHY2/wiki \n"
|
||||||
"Thank you so much for supporting this project!\n"
|
"Thank you so much for supporting this project!\n"
|
||||||
|
|
||||||
, TEXT_TO_ENCRYPT, encryptedText
|
, TEXT_TO_ENCRYPT, encryptedText.outputText
|
||||||
);
|
);
|
||||||
|
|
||||||
free(encryptedText);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -7,8 +7,7 @@
|
|||||||
#include <why2/flags.h>
|
#include <why2/flags.h>
|
||||||
#include <why2/misc.h>
|
#include <why2/misc.h>
|
||||||
|
|
||||||
char*
|
outputFlags decryptText(char *text, char *key, inputFlags flags)
|
||||||
decryptText(char *text, char *key)
|
|
||||||
{
|
{
|
||||||
//CHECK FOR INVALID key
|
//CHECK FOR INVALID key
|
||||||
if (strlen(key) < getKeyLength())
|
if (strlen(key) < getKeyLength())
|
||||||
@ -83,8 +82,15 @@ decryptText(char *text, char *key)
|
|||||||
returningText[i] = (char) textKeyChain[i];
|
returningText[i] = (char) textKeyChain[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//LOAD output
|
||||||
|
outputFlags output =
|
||||||
|
{
|
||||||
|
returningText, //DECRYPTED TEXT
|
||||||
|
key //USED KEY
|
||||||
|
};
|
||||||
|
|
||||||
//DEALLOCATION
|
//DEALLOCATION
|
||||||
free(textKeyChain);
|
free(textKeyChain);
|
||||||
|
|
||||||
return returningText;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,7 @@
|
|||||||
#include <why2/flags.h>
|
#include <why2/flags.h>
|
||||||
#include <why2/misc.h>
|
#include <why2/misc.h>
|
||||||
|
|
||||||
char*
|
outputFlags encryptText(char *text, char *keyNew, inputFlags flags)
|
||||||
encryptText(char *text, char *keyNew)
|
|
||||||
{
|
{
|
||||||
//CHECK FOR ACTIVE VERSION
|
//CHECK FOR ACTIVE VERSION
|
||||||
checkVersion();
|
checkVersion();
|
||||||
@ -58,8 +57,6 @@ encryptText(char *text, char *keyNew)
|
|||||||
key[i] = (char) numberBuffer;
|
key[i] = (char) numberBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getNoOutput()) printf("Your key is: %s\n!!! SAVE IT SOMEWHERE !!!\n\n", key);
|
|
||||||
|
|
||||||
skipKey:
|
skipKey:
|
||||||
|
|
||||||
//LOAD textKeyChain
|
//LOAD textKeyChain
|
||||||
@ -98,8 +95,15 @@ encryptText(char *text, char *keyNew)
|
|||||||
free(textBuffer);
|
free(textBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//LOAD output
|
||||||
|
outputFlags output =
|
||||||
|
{
|
||||||
|
returningText, //ENCRYPTED TEXT
|
||||||
|
key //GENERATED/USED KEY
|
||||||
|
};
|
||||||
|
|
||||||
//DEALLOCATION
|
//DEALLOCATION
|
||||||
free(key);
|
free(key);
|
||||||
|
|
||||||
return returningText;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -6,18 +6,18 @@
|
|||||||
#include <why2/decrypter.h>
|
#include <why2/decrypter.h>
|
||||||
#include <why2/flags.h>
|
#include <why2/flags.h>
|
||||||
|
|
||||||
int
|
int main(void)
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
{
|
||||||
if (argc == 2 && strcmp(argv[1], "skipCheck") == 0)
|
inputFlags flags =
|
||||||
{
|
{
|
||||||
setSkipCheck(1);
|
1, //SKIP CHECK
|
||||||
}
|
0, //NO OUTPUT
|
||||||
|
};
|
||||||
|
|
||||||
char *text = encryptText(TEST_TEXT, TEST_KEY);
|
outputFlags encrypted = encryptText(TEST_TEXT, TEST_KEY, flags);
|
||||||
text = decryptText(text, TEST_KEY);
|
encrypted = decryptText(encrypted.outputText, TEST_KEY, flags);
|
||||||
|
|
||||||
if (strcmp(text, TEST_TEXT) == 0)
|
if (strcmp(encrypted.outputText, TEST_TEXT) == 0)
|
||||||
{
|
{
|
||||||
printf("Test successful!\n");
|
printf("Test successful!\n");
|
||||||
}
|
}
|
||||||
@ -27,6 +27,5 @@ main(int argc, char *argv[])
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(text);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user