From d2e94cb263ab933103e1968c0f3da638f35f5983 Mon Sep 17 00:00:00 2001 From: Benedict Date: Fri, 4 Mar 2016 10:54:20 +0100 Subject: added task 1 agian in new infrastrucre also added a test for task1 --- Makefile | 5 ++++- task1.c | 22 ++++++++++++++++++++++ test.sh | 12 +++++++++++- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 task1.c diff --git a/Makefile b/Makefile index 5e5d683..2178244 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,10 @@ LIB=lib.c CC=gcc -all: task4 task5 task6 +all: task1 task4 task5 task6 + +task1: + $(CC) task1.c $(LIB) -o task1 task4: $(CC) task4.c $(LIB) -o task4 diff --git a/task1.c b/task1.c new file mode 100644 index 0000000..886365b --- /dev/null +++ b/task1.c @@ -0,0 +1,22 @@ +#include "lib.h" + + +int main(int argc, char **argv) +{ + if (argc != 2) + return 0; + + + char *result = malloc(strlen(argv[1])); + char *base64 = malloc(strlen(argv[1])); + + decode_hex_string(argv[1], result); + encode_to_base64(result, base64); + + printf("%s\n", base64); + + free(result); + free(base64); + return 0; + +} diff --git a/test.sh b/test.sh index db65f09..a728fa0 100644 --- a/test.sh +++ b/test.sh @@ -6,11 +6,12 @@ test_compare_string() { then echo "test ok" else - echo "test broken" + echo "test failed" fi } test_set1_challenge5() { +echo "test: set1, challenge 5:" OUTPUT=$(./task5) EXCEPTED="0b3637272a2b2e63622c2e69692a23693a2a3c6324202d623d63343c2a26226324272765272a282b2f20430a652e2c652a3124333a653e2b2027630c692b20283165286326302e27282f" @@ -19,4 +20,13 @@ test_compare_string "$OUTPUT" "$EXCEPTED" } +test_set1_challenge1() { +echo "test: set1, challenge 1:" +OUTPUT=$(./task1 49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d) +EXCEPTED="SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t" + +test_compare_string "$OUTPUT" "$EXCEPTED" +} + +test_set1_challenge1 test_set1_challenge5 -- cgit v1.2.3-70-g09d2