-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathprogram.c
66 lines (48 loc) · 1.29 KB
/
program.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include "coolsdk/cool.h"
void encrypt() {
printf("Type the message to encrypt: ");
char input[9001];
scanf(" %9000[^\n]", input);
int len = strlen(input);
printf("Type numeric key code to encrypt with: ");
int key;
scanf("%d", &key);
char* output = coolStringEncrypt(input, key, len);
printHexString(output, len);
free(output);
}
void decrypt() {
printf("Type the message to decrypt: ");
char input[9001];
scanf(" %9000[^\n]", input);
int len = strlen(input);
printf("Type numeric key code to decrypt with: ");
int key;
scanf("%d", &key);
char* newInput = parseHexString(input, len);
len /= 2;
char* output = coolStringDecrypt(newInput, key, len);
printf("%s\n", output);
free(newInput);
free(output);
}
int main() {
printf("Welcome to my cool encryptor program!\n");
while (true) {
printf("Encrypt (0), decrypt (1), or exit (2)?\n");
int choice;
scanf("%d", &choice);
if (choice == 0) {
encrypt();
} else if (choice == 1) {
decrypt();
} else if (choice == 2) {
printf("Goodbye!");
break;
}
}
}