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 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 generateTextKeyChain(char key[], int *textKeyChain, int textKeyChainSize); //GENERATES ARRAY FOR ENCRYPTION/DECRYPTION
|
||||||
void deallocateOutput(outputFlags flags); //DEALLOCATES flags
|
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
|
int countIntLength(int number); //RETURNS LENGTH OF number
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -10,11 +10,7 @@
|
|||||||
outputFlags decryptText(char *text, char *key, inputFlags flags)
|
outputFlags decryptText(char *text, char *key, inputFlags flags)
|
||||||
{
|
{
|
||||||
//CHECK FOR INVALID key
|
//CHECK FOR INVALID key
|
||||||
if (strlen(key) < getKeyLength())
|
checkKey(key, flags);
|
||||||
{
|
|
||||||
if (!flags.noOutput) fprintf(stderr, "Key must be at least %d characters long!\n", getKeyLength());
|
|
||||||
exit(INVALID_KEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
//REDEFINE keyLength
|
//REDEFINE keyLength
|
||||||
setKeyLength(strlen(key));
|
setKeyLength(strlen(key));
|
||||||
|
@ -29,11 +29,7 @@ outputFlags encryptText(char *text, char *keyNew, inputFlags flags)
|
|||||||
|
|
||||||
if (keyNew != NULL)
|
if (keyNew != NULL)
|
||||||
{
|
{
|
||||||
if (strlen(keyNew) < getKeyLength())
|
checkKey(key, flags); //CHECK FOR INVALID key
|
||||||
{
|
|
||||||
if (!flags.noOutput) fprintf(stderr, "Key must be at least %d characters long!\n", getKeyLength());
|
|
||||||
exit(INVALID_KEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(key, keyNew);
|
strcpy(key, keyNew);
|
||||||
|
|
||||||
|
@ -168,6 +168,15 @@ void deallocateOutput(outputFlags flags)
|
|||||||
free(flags.usedKey);
|
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 countIntLength(int number)
|
||||||
{
|
{
|
||||||
int returning = 1;
|
int returning = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user