implemented math callbacks in TKCh generation => made code easier

part 3/3 (done lol)
This commit is contained in:
Václav Šmejkal 2022-07-22 17:46:37 +02:00
parent 6a821910f3
commit 340834adf6
No known key found for this signature in database
GPG Key ID: FD749A97DF2D5E19

View File

@ -263,6 +263,7 @@ void generateTextKeyChain(char *key, int *textKeyChain, int textKeyChainSize)
{
int numberBuffer;
int numberBuffer2;
double (*cb)(int, int);
for (int i = 0; i < textKeyChainSize; i++)
{
@ -279,16 +280,18 @@ void generateTextKeyChain(char *key, int *textKeyChain, int textKeyChainSize)
//FILL textKeyChain
if ((numberBuffer + 1) % 3 == 0)
{
textKeyChain[textKeyChainSize - (i + 1)] = key[numberBuffer] * key[numberBuffer2];
cb = multiply_cb;
}
else if ((numberBuffer + 1) % 2 == 0)
{
textKeyChain[textKeyChainSize - (i + 1)] = key[numberBuffer] - key[numberBuffer2];
cb = subtract_cb;
}
else
{
textKeyChain[textKeyChainSize - (i + 1)] = key[numberBuffer] + key[numberBuffer2];
cb = sum_cb;
}
textKeyChain[textKeyChainSize - (i + 1)] = doMathematicalOperation(key[numberBuffer], key[numberBuffer2], cb);
}
}