From 2c4aadf08fbc8a28f85855a39b2aa9fccae80bde Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Sun, 6 Mar 2022 16:00:15 +0100 Subject: [PATCH] created code for encrypting every character --- src/encrypter.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/encrypter.c b/src/encrypter.c index 2e8cf6b..0fcd78f 100644 --- a/src/encrypter.c +++ b/src/encrypter.c @@ -1,5 +1,6 @@ #include #include +#include #include #define KEY_LENGTH 50 @@ -11,6 +12,7 @@ encryptText(char *text) //VARIABLES char *key = malloc(KEY_LENGTH); + int textKeyChain[strlen(text)]; int numberBuffer; //LOAD KEY @@ -33,6 +35,30 @@ encryptText(char *text) printf("Your key is: %s\n!!! SAVE IT SOMEWHERE !!!\n\n", key); + //LOAD textKeyChain + for (int i = 0; i < (sizeof(textKeyChain) / sizeof(int)); i++) + { + numberBuffer = i; + + //CHECK, IF numberBuffer ISN'T GREATER THAN KEY_LENGTH AND CUT UNUSED LENGTH + while (numberBuffer >= 50) + { + numberBuffer -= 50; + } + + //FILL textKeyChain + if ((numberBuffer + 1) % 3 == 0) + { + textKeyChain[i] = key[numberBuffer] * key[numberBuffer + 1]; + } else if ((numberBuffer + 1) % 2 == 0) + { + textKeyChain[i] = key[numberBuffer] - key[numberBuffer + 1]; + } else + { + textKeyChain[i] = key[numberBuffer] + key[numberBuffer + 1]; + } + } + exit(0); return NULL; } \ No newline at end of file