update ecrypt_check

This commit is contained in:
Liam Waldron 2023-05-31 11:44:09 -04:00
parent b2e8d891be
commit f474115853

View File

@ -5,13 +5,6 @@
#include <stdlib.h>
#include <time.h>
/*
key_status
0 - keys match
1 - keys do not match
*/
int key_status;
void
ecrypt_gen(int N)
{
@ -53,12 +46,6 @@ ecrypt_gen(int N)
}
}
/*
Return values for ecrypt_check:
0 - keys match
1 - keys do not match
2 - error opening key
*/
int
ecrypt_check(char *firstkey, char *secondkey)
{
@ -72,8 +59,7 @@ ecrypt_check(char *firstkey, char *secondkey)
key1 = fopen(firstkey, "r");
if (key1 == NULL) {
printf("error opening %s\n", firstkey);
key_status = 2;
return key_status;
return 1;
}
fseek(key1, 0, SEEK_END);
@ -82,16 +68,15 @@ ecrypt_check(char *firstkey, char *secondkey)
key2 = fopen(secondkey, "r");
if (key2 == NULL) {
printf("error opening %s\n", secondkey);
key_status = 2;
return key_status;
return 1;
}
fseek(key2, 0, SEEK_END);
cnt1 = ftell(key2);
if (cnt1 != cnt2) {
key_status = 1;
return key_status;
printf("no match\n");
return 1;
} else {
while (! feof(key1)) {
if (fgetc(key1) != fgetc(key2)) {
@ -100,11 +85,11 @@ ecrypt_check(char *firstkey, char *secondkey)
}
}
if (flg) {
key_status = 1;
return key_status;
printf("no match\n");
return 1;
} else {
key_status = 0;
return key_status;
printf("match\n");
return 0;
}
}