-
Notifications
You must be signed in to change notification settings - Fork 3
/
example.c
51 lines (43 loc) · 1 KB
/
example.c
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "hex.h"
void example1() {
char str[] = "test";
printf("Hex Encoded: %s", hexenc(str));
}
void example2() {
char str[] = "74657374";
printf("Hex Decoded: %s", hexdec(str));
}
void example3() {
char string_plain[] = "test";
const char* string_enc = hexenc(string_plain);
printf("Hex Encoded: %s\n", string_enc);
printf("Hex Decoded: %s", hexdec(string_enc));
}
int main() {
char choose[10];
char choose_1[] = "1";
printf(R"EOF(
[1] 1º Example
[2] 2º Example
[3] 3º Example
)EOF");
printf("Choose an example: ");
scanf("%10s", choose);
if (strncmp(choose, "1", strlen(choose)) == 0) {
printf("\n");
example1();
}
else if (strncmp(choose, "2", strlen(choose)) == 0) {
printf("\n");
example2();
}
else if (strncmp(choose, "3", strlen(choose)) == 0) {
printf("\n");
example3();
} else {
printf("\nWrong choose.");
}
}