created code for encrypting every character

This commit is contained in:
Václav Šmejkal 2022-03-06 16:00:15 +01:00
parent d310aa25b4
commit 2c4aadf08f

View File

@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#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;
}