moved checking for valid key to misc
I'm trying to make code variable as much as possible
This commit is contained in:
parent
39e174a874
commit
073cdd2468
@ -6,6 +6,7 @@
|
||||
void checkVersion(inputFlags flags); //THIS FUNCTION CHECKS IF LATEST VERSION OF WHY2 IS USED
|
||||
void generateTextKeyChain(char key[], int *textKeyChain, int textKeyChainSize); //GENERATES ARRAY FOR ENCRYPTION/DECRYPTION
|
||||
void deallocateOutput(outputFlags flags); //DEALLOCATES flags
|
||||
void checkKey(char *key, inputFlags flags); //CHECKS IF KEY IS VALID
|
||||
int countIntLength(int number); //RETURNS LENGTH OF number
|
||||
|
||||
#endif
|
||||
|
@ -10,11 +10,7 @@
|
||||
outputFlags decryptText(char *text, char *key, inputFlags flags)
|
||||
{
|
||||
//CHECK FOR INVALID key
|
||||
if (strlen(key) < getKeyLength())
|
||||
{
|
||||
if (!flags.noOutput) fprintf(stderr, "Key must be at least %d characters long!\n", getKeyLength());
|
||||
exit(INVALID_KEY);
|
||||
}
|
||||
checkKey(key, flags);
|
||||
|
||||
//REDEFINE keyLength
|
||||
setKeyLength(strlen(key));
|
||||
|
@ -29,11 +29,7 @@ outputFlags encryptText(char *text, char *keyNew, inputFlags flags)
|
||||
|
||||
if (keyNew != NULL)
|
||||
{
|
||||
if (strlen(keyNew) < getKeyLength())
|
||||
{
|
||||
if (!flags.noOutput) fprintf(stderr, "Key must be at least %d characters long!\n", getKeyLength());
|
||||
exit(INVALID_KEY);
|
||||
}
|
||||
checkKey(key, flags); //CHECK FOR INVALID key
|
||||
|
||||
strcpy(key, keyNew);
|
||||
|
||||
|
@ -168,6 +168,15 @@ void deallocateOutput(outputFlags flags)
|
||||
free(flags.usedKey);
|
||||
}
|
||||
|
||||
void checkKey(char *key, inputFlags flags)
|
||||
{
|
||||
if (strlen(key) < getKeyLength())
|
||||
{
|
||||
if (!flags.noOutput) fprintf(stderr, "Key must be at least %d characters long!\n", getKeyLength());
|
||||
exit(INVALID_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
int countIntLength(int number)
|
||||
{
|
||||
int returning = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user