diff options
| author | Benedict <benedict@0xb8000.de> | 2016-03-03 21:49:01 +0100 |
|---|---|---|
| committer | Benedict <benedict@0xb8000.de> | 2017-02-21 13:00:24 +0100 |
| commit | bd7b98c2aac8fdfd128aff832c663d60d3374d63 (patch) | |
| tree | 45b71ac2935cbf9f64e6e892b912868990af7c75 /task4.c | |
| parent | 383732972f4c00dce231f61ac7375ae212e0d9c7 (diff) | |
reorgantzied code into libaray file
For every task you may create a new file and implenet the task there by
using functions from the lib.c file.
Added Makefile for the different tasks.
Diffstat (limited to 'task4.c')
| -rw-r--r-- | task4.c | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -0,0 +1,41 @@ + +#include "lib.h" + +void main() { + /** read the file */ + FILE *fp; + int bytes_read; + int malloc_size = 62; + int line_number = 0; + int j; + char *string = malloc(malloc_size); + char *string2 = malloc(malloc_size); + char *cleartext = malloc(malloc_size); + char *keys = malloc(255); + char single_key; + int length; + + fp = fopen("4.txt", "r"); + + if (fp == NULL) { + printf("Error open file\n"); + exit(1); + } + + while (fscanf(fp, "%61c", string) != EOF) { + j = decode_hex_string(string, string2); + length = brute_force_single_byte_xor(string2, j, keys); + if (length > 0) { + printf("line %i:\n", line_number); + for(j=0;j<length;j++) { + single_key = keys[j]; + xor_string(string2, &single_key, cleartext); + printf("%s\n", cleartext); + } + } + line_number++; + } + + fclose(fp); + +} |
