diff --git a/include/encrypter.h b/include/encrypter.h index b7564f3..57df388 100644 --- a/include/encrypter.h +++ b/include/encrypter.h @@ -1,4 +1,6 @@ #ifndef WHY2_ENCRYPTER_H #define WHY2_ENCRYPTER_H +char *encryptText(char from[]); //TEXT from WILL BE ENCRYPTED WITH RANDOM PASSWORD (WHICH WILL BE PRINTED OUT) AND RETURNED + #endif \ No newline at end of file diff --git a/src/encrypter.c b/src/encrypter.c index e69de29..41a9265 100644 --- a/src/encrypter.c +++ b/src/encrypter.c @@ -0,0 +1,39 @@ +#include +#include +#include + +#define KEY_LENGTH 50 + +char* +encryptText(char *from) +{ + srand(time(0)); //TRY TO MAKE RANDOM GENERATION REALLY "RANDOM" + + //VARIABLES + char *key = malloc(KEY_LENGTH); + int numberBuffer; + + //LOAD KEY + for (int i = 0; i < KEY_LENGTH; i++) + { + //SET numberBuffer TO RANDOM NUMBER BETWEEN 0 AND 52 + numberBuffer = rand() % 52; + numberBuffer++; + + //GET CHAR FROM numberBuffer + if (numberBuffer > 26) + { + numberBuffer += 70; + } else + { + numberBuffer += 64; + } + + key[i] = (char) numberBuffer; + } + + printf("Your key is: %s\n!!! SAVE IT SOMEWHERE !!!\n\n", key); + + exit(0); + return NULL; +} \ No newline at end of file