added unusedKeySize to outputFlags

this returns positive number, which represents how many chars from key are unused
This commit is contained in:
Václav Šmejkal 2022-05-30 18:01:21 +02:00
parent 96945a4d31
commit abbe519ab4
No known key found for this signature in database
GPG Key ID: FD749A97DF2D5E19
5 changed files with 18 additions and 2 deletions

View File

@ -32,6 +32,7 @@ typedef struct
{
char *outputText; //VARIABLE FOR ENCRYPTED/DECRYPTED TEXT
char *usedKey; //VARIABLE FOR USED/GENERATED KEY
unsigned long unusedKeySize;
} outputFlags;
//VARIABLES

View File

@ -9,5 +9,6 @@ void deallocateOutput(outputFlags flags); //DEALLOCATES flags
void checkKey(char *key, inputFlags flags); //CHECKS IF KEY IS VALID
void checkText(char *text, inputFlags flags); //CHECKS IF TEXT IS VALID
unsigned long countIntLength(int number); //RETURNS LENGTH OF number
unsigned long countUnusedKeySize(char *text, char *key); //COUNT unusedKeySize
#endif

View File

@ -96,7 +96,8 @@ outputFlags decryptText(char *text, char *keyNew, inputFlags flags)
outputFlags output =
{
returningText, //DECRYPTED TEXT
key //USED KEY
key, //USED KEY
countUnusedKeySize(text, key)
};
//DEALLOCATION

View File

@ -116,7 +116,8 @@ outputFlags encryptText(char *text, char *keyNew, inputFlags flags)
outputFlags output =
{
returningText, //ENCRYPTED TEXT
key //GENERATED/USED KEY
key, //GENERATED/USED KEY
countUnusedKeySize(text, key) // NUMBER OF UNUSED CHARS IN KEY
};
//DEALLOCATION

View File

@ -211,3 +211,15 @@ unsigned long countIntLength(int number)
return returning;
}
unsigned long countUnusedKeySize(char *text, char *key)
{
unsigned long returning = 0;
if (strlen(key) / 2 > strlen(text))
{
returning = strlen(key) - 2 * strlen(text);
}
return returning;
}