From ff0652a3d1e32254ddd72b425c47ff0309d1468b Mon Sep 17 00:00:00 2001 From: Seppia Date: Sun, 18 Dec 2016 05:17:19 +0100 Subject: removed old sources files --- old_code/keygen.c | 60 --------------------------------------------------- old_code/read_crypt.c | 43 ------------------------------------ old_code/rosicchio.c | 43 ------------------------------------ 3 files changed, 146 deletions(-) delete mode 100644 old_code/keygen.c delete mode 100644 old_code/read_crypt.c delete mode 100644 old_code/rosicchio.c diff --git a/old_code/keygen.c b/old_code/keygen.c deleted file mode 100644 index b03b89c..0000000 --- a/old_code/keygen.c +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include -#include - -int main(int argc, char* argv[]) { - - int opt; - int nbytes = 256; - char* defname = "default.key"; - char* output; - int defout = 0; - int defbyte = 0; - int noopts = 0; - while ((opt = getopt(argc, argv, "b:o:")) != -1) { - switch (opt) { - case 'b': - nbytes = atoi(optarg); - defbyte = 1; - break; - case 'o': - output = argv[(optind-1)]; - defout = 1; - break; - default: - fprintf(stderr, "Usage: %s [-b nbytes] [-o output] \n", argv[0]); - exit(EXIT_FAILURE); - } - if (noopts == 0) { - noopts = 1; - } - } - - if(noopts == 0) { - printf("WARNING no option specified usign default values... \n"); - } - if (nbytes < 0) { - printf("Negative byte value inserted! \n"); - printf("Exiting... \n"); - exit(EXIT_FAILURE); - } else if (nbytes != 0) { - if (defbyte == 0) { - printf("No byte number specified... using default value: 256 \n"); - } - unsigned char key[nbytes]; - RAND_bytes(key, nbytes); - if (defout == 0) { - output = defname; - printf("No output name specified... using default value: default.key \n"); - } - FILE* file = fopen(output, "w"); - fwrite(key, nbytes, 1, file); - fclose(file); - printf("Created key file %s of %d bytes \n", output, nbytes); - } else { - printf("Byte number specified is 0. \n"); - printf("Doing nothing! \n"); - } - - exit(EXIT_SUCCESS); -} diff --git a/old_code/read_crypt.c b/old_code/read_crypt.c deleted file mode 100644 index af3a7c0..0000000 --- a/old_code/read_crypt.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include - -int main(int argc, char *argv[]) { -//reads a message <4096B and XORs it with key argv[1] in file argv[2] -//message ends with string "@@@" after a white character. -//To retrieve the original message, use onetimebluh.c -FILE * keyfile = fopen(argv[1],"r"); -FILE * crypt = fopen(argv[2],"w"); -char msg[4096]; - -printf("Write a message.\n It will be encrypted in file %s ",argv[2]); -printf("with key %s\n",argv[1]); -printf("When you're done, use the EOF sequence @@@. It must follow a white space!\n"); - -char c_aux; -int i=0,k=0; -//scanf terminates at every white character, must be called by a While -// "i" tells where you are in msg (which is overwritten each time) -// "k" tells where you are in crypt -while(strcmp(msg,"@@@")) - { - scanf("%s",msg); - i=0; - while(msg[i]!='\0') { - fscanf(keyfile,"%c", &c_aux); - fprintf(crypt,"%c",msg[i]^c_aux); - i++; - k++; - } - fscanf(keyfile,"%c",&c_aux); - fprintf(crypt,"%c",' '^c_aux); - k++; - } - -while (k<4096){ -// fills the message with @s - fscanf(keyfile,"%c",&c_aux); - fprintf(crypt,"%c",'@'^c_aux); - k++;} -fclose(crypt); -} diff --git a/old_code/rosicchio.c b/old_code/rosicchio.c deleted file mode 100644 index ffd3ee8..0000000 --- a/old_code/rosicchio.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include - -int main(int argc, char* argv[]) { - - FILE* mess = fopen(argv[1], "r"); - FILE* pad = fopen(argv[2], "r+"); - FILE* critt = fopen(argv[3],"w"); - fseek(mess, 0L, SEEK_END); - long mess_size = ftell(mess); - rewind(mess); - fseek(pad, 0L, SEEK_END); - long pad_size = ftell(pad); - fseek(pad, (pad_size - mess_size), SEEK_SET); - int i = 1; - char a, b; - - while(i != EOF) { - i = fscanf(mess, "%c", &a); - fscanf(pad, "%c", &b); - if(i != EOF) { - fprintf(critt, "%c", a^b); - } - } - - /* The truncate function "rosicchia" la parte di chiave utilizzata */ - - ftruncate(fileno(pad), (pad_size - mess_size)); - fseek(pad, 0L, SEEK_END); - long new_pad_size = ftell(pad); - - fclose(mess); - fclose(pad); - fclose(critt); - - printf("Message length is %li bytes \n", mess_size); - printf("Pad length was %li bytes \n", pad_size); - printf("Pad length is now %li bytes \n", new_pad_size); - printf("Pad length should now be %li bytes \n", (pad_size - mess_size)); - - exit(EXIT_SUCCESS); -} -- cgit v1.2.3