diff options
author | Seppia <nonso@insicuri.net> | 2016-11-26 18:31:56 +0100 |
---|---|---|
committer | Seppia <nonso@insicuri.net> | 2016-11-26 18:31:56 +0100 |
commit | f7a628df43e87acc159924c1dd3cc5665cf5ca2e (patch) | |
tree | 663121eaea7b51dac9fc20ee4d109aa105115770 | |
parent | 633580adeb5d85286e9390a43a7479e4aa917896 (diff) | |
download | onetimebluh-f7a628df43e87acc159924c1dd3cc5665cf5ca2e.tar.gz onetimebluh-f7a628df43e87acc159924c1dd3cc5665cf5ca2e.tar.bz2 onetimebluh-f7a628df43e87acc159924c1dd3cc5665cf5ca2e.zip |
changed xor output writing from fprintf to fwrite
-rw-r--r-- | src/onetimebluh.c | 16 |
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); |