-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathchallenge_02.c
More file actions
26 lines (20 loc) · 689 Bytes
/
Copy pathchallenge_02.c
File metadata and controls
26 lines (20 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "hex.h"
#include "xor.h"
#include "bin.h"
int main(int argc, char** argv) {
printf("Cryptopals Set 1, Challenge 2 XOR\n");
uint8_t lhs[] = "1c0111001f010100061a024b53535009181c";
uint8_t rhs[] = "686974207468652062756c6c277320657965";
uint8_t* expected = {"746865206b696420646f6e277420706c6179"};
printf("Input 1: %s\n", lhs);
printf("Input 2: %s\n", rhs);
uint8_t* xored = xor_hex(lhs, strlen(lhs), rhs, strlen(rhs));
uint8_t* actual = bin_to_hex(xored, binary_len_of_hex(lhs));
printf("Expected :%s\n", expected);
printf("Actual :");
print_hex(actual, strlen(lhs));
}