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 *outputText; //VARIABLE FOR ENCRYPTED/DECRYPTED TEXT
|
||||||
char *usedKey; //VARIABLE FOR USED/GENERATED KEY
|
char *usedKey; //VARIABLE FOR USED/GENERATED KEY
|
||||||
|
unsigned long unusedKeySize;
|
||||||
} outputFlags;
|
} outputFlags;
|
||||||
|
|
||||||
//VARIABLES
|
//VARIABLES
|
||||||
|
@ -9,5 +9,6 @@ void deallocateOutput(outputFlags flags); //DEALLOCATES flags
|
|||||||
void checkKey(char *key, inputFlags flags); //CHECKS IF KEY IS VALID
|
void checkKey(char *key, inputFlags flags); //CHECKS IF KEY IS VALID
|
||||||
void checkText(char *text, inputFlags flags); //CHECKS IF TEXT IS VALID
|
void checkText(char *text, inputFlags flags); //CHECKS IF TEXT IS VALID
|
||||||
unsigned long countIntLength(int number); //RETURNS LENGTH OF number
|
unsigned long countIntLength(int number); //RETURNS LENGTH OF number
|
||||||
|
unsigned long countUnusedKeySize(char *text, char *key); //COUNT unusedKeySize
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -96,7 +96,8 @@ outputFlags decryptText(char *text, char *keyNew, inputFlags flags)
|
|||||||
outputFlags output =
|
outputFlags output =
|
||||||
{
|
{
|
||||||
returningText, //DECRYPTED TEXT
|
returningText, //DECRYPTED TEXT
|
||||||
key //USED KEY
|
key, //USED KEY
|
||||||
|
countUnusedKeySize(text, key)
|
||||||
};
|
};
|
||||||
|
|
||||||
//DEALLOCATION
|
//DEALLOCATION
|
||||||
|
@ -116,7 +116,8 @@ outputFlags encryptText(char *text, char *keyNew, inputFlags flags)
|
|||||||
outputFlags output =
|
outputFlags output =
|
||||||
{
|
{
|
||||||
returningText, //ENCRYPTED TEXT
|
returningText, //ENCRYPTED TEXT
|
||||||
key //GENERATED/USED KEY
|
key, //GENERATED/USED KEY
|
||||||
|
countUnusedKeySize(text, key) // NUMBER OF UNUSED CHARS IN KEY
|
||||||
};
|
};
|
||||||
|
|
||||||
//DEALLOCATION
|
//DEALLOCATION
|
||||||
|
@ -211,3 +211,15 @@ unsigned long countIntLength(int number)
|
|||||||
|
|
||||||
return returning;
|
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