From ac82127bccdd6ea1d5d4ec93a31011bd0fb12d32 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Sun, 29 May 2022 16:44:14 +0200 Subject: [PATCH] fixed decryption returningText bugs I forgot that newly allocated text has some content.... --- src/lib/decrypter.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/decrypter.c b/src/lib/decrypter.c index b206590..cfdd19f 100644 --- a/src/lib/decrypter.c +++ b/src/lib/decrypter.c @@ -42,7 +42,7 @@ outputFlags decryptText(char *text, char *keyNew, inputFlags flags) generateTextKeyChain(key, textKeyChain, numberBuffer); //LOAD encryptedTextKeyChain - for (int i = 0; i < (sizeof(encryptedTextKeyChain) / sizeof(int)); i++) + for (int i = 0; i < textKeyChainLength; i++) { numberBuffer = 0; @@ -76,10 +76,17 @@ outputFlags decryptText(char *text, char *keyNew, inputFlags flags) textKeyChain[i] -= encryptedTextKeyChain[i]; } + //FIX returningText + strcpy(returningText, ""); + for (int i = 0; i < textKeyChainLength; i++) + { + strcat(returningText, " "); + } + //LOAD returningText for (int i = 0; i < textKeyChainLength; i++) { - returningText[i] = (char) textKeyChain[i]; + returningText[i] = textKeyChain[i]; } //LOAD output