added unusedKeySize to outputFlags
this returns positive number, which represents how many chars from key are unused
This commit is contained in:
parent
96945a4d31
commit
abbe519ab4
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user