add checking function

This commit is contained in:
Liam Waldron 2023-05-30 10:19:12 -04:00
parent d6f3e860f6
commit 455b3481fd

View File

@ -5,7 +5,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
void ecrypt(int N) { void
ecrypt_gen(int N)
{
int c = 0; int c = 0;
int randomizer = 0; int randomizer = 0;
@ -43,3 +45,51 @@ void ecrypt(int N) {
} }
} }
} }
int
ecrypt_check(char *firstkey, char *secondkey)
{
FILE *key1;
FILE *key2;
int cnt1 = 0;
int cnt2 = 0;
int flg = 0;
key1 = fopen(firstkey, "r");
if (key1 == NULL) {
printf("error opening %s\n", firstkey);
return 2;
}
fseek(key1, 0, SEEK_END);
cnt1 = ftell(key1);
key2 = fopen(secondkey, "r");
if (key2 == NULL) {
printf("error opening %s\n", secondkey);
return 2;
}
fseek(key2, 0, SEEK_END);
cnt1 = ftell(key2);
if (cnt1 != cnt2) {
return 1;
} else {
while (! feof(key1)) {
if (fgetc(key1) != fgetc(key2)) {
flg = 1;
break;
}
}
if (flg) {
return 1;
} else {
return 0;
}
}
fclose(key1);
fclose(key2);
}