summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/onetimebluh.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/onetimebluh.c b/src/onetimebluh.c
index 85ad4fa..ae81b5c 100644
--- a/src/onetimebluh.c
+++ b/src/onetimebluh.c
@@ -150,17 +150,19 @@ void xor(int ed, char* mess, char* keyf, char* outp) {
pad_size = ftell(keyx);
fseek(keyx, (pad_size - mess_size), SEEK_SET);
- int i = 1;
+ char* mexstream = malloc(mess_size);
+
+ long i;
char a, b;
- while (i != EOF) {
- i = fscanf(mex, "%c", &a);
+ for (i = 0; i < mess_size; i ++) {
+ fscanf(mex, "%c", &a);
fscanf(keyx, "%c", &b);
- if(i != EOF) {
- fprintf(critt, "%c", a^b);
- }
+ mexstream[i] = a ^ b;
}
+ fwrite(mexstream, sizeof(char), mess_size, critt);
+
if (ed == 'f' || ed == 'v') {
ftruncate(fileno(keyx), (pad_size - mess_size));
fseek(keyx, 0L, SEEK_END);
@@ -169,6 +171,8 @@ void xor(int ed, char* mess, char* keyf, char* outp) {
printf("You now have %li bytes left \n", new_pad_size);
}
+ free(mexstream);
+
fclose(mex);
fclose(keyx);
fclose(critt);