/* *driver and file reader function */ int main() { FILE *file = fopen("../cipher.txt", "r"); int n = 0; int c; char i; char j; char k; char *inputcsv = (char *)malloc(4096*sizeof(char)); char *cleanctxt; char *key = (char *)malloc(4*sizeof(char)); char *dec; while ((c = fgetc(file)) != EOF) inputcsv[n++] = (char)c; if (n<0) exit(1); fclose(file); cleanctxt = parsecsv(inputcsv,n); key[3] = '\0'; /*try all combinations of aaa - zzz*/ for (i=95; i<123; ++i) { key[0] = i; for (j=95; j<123; ++j) { key[1] = j; for (k=95; k<123; ++k) { key[2] = k; /*if found, print relevant stats on the decrypted text*/ if ( checkenglish(xordecrypt(key,gl_cleanbytes-1,cleanctxt), 95, gl_cleanbytes) ) { dec = xordecrypt(key,gl_cleanbytes,cleanctxt); my_str("Key: "); my_str(key); my_char('\n'); my_str("Sum of ASCII Values: "); printf("%d\n",(addasciivals(dec))); my_str(dec); my_char('\n'); return 0; } } } } return 1; }
int main(int argc, char* argv[]){ if (argc < 2) { fprintf(stderr, "Input a command file\n"); return 1; } char* cmdIn = argv[1]; printf("\nReading the CSV files in directory ./input/.........\n"); if ( !parsecsv() ) { fprintf(stderr, "MemInit Unsuccessful\n"); } else{ printf("CSV files Read Successful, Memory Initialized!...........\n\n"); } globalNCmds = genCommand(cmdIn, globalCmdEntryBuff); printf("command dump BEFORE execution:\n"); for (uint32_t i=0; i<globalNCmds; i++){ dumpCmdEntry(globalCmdEntryBuff[i]); } runProcModel(); printf("command dump AFTER execution:\n"); for (uint32_t i=0; i<globalNCmds; i++){ dumpCmdEntry(globalCmdEntryBuff[i]); } dumpTableMetas(); printf("\n************************************\n"); printf("Final table values:\n"); for (uint32_t i=0; i<globalNextMeta; i++){ printTable(i); } return 0; }