-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
35 lines (28 loc) · 685 Bytes
/
main.c
File metadata and controls
35 lines (28 loc) · 685 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
27
28
29
30
31
32
33
34
35
#include "ui.h"
#include "cipher.h"
#define SUCCESS 0
#define FAILURE -1
#define MESSAGE_SIZE 100
int main()
{
char message[MESSAGE_SIZE];
const int action = get_action();
const int key = get_key();
const int message_result = get_message(message, MESSAGE_SIZE);
if (action == INVALID_INPUT ||
key == INVALID_INPUT ||
message_result == INVALID_INPUT )
{
return FAILURE;
}
if (action == ENCRYPT_CHOSEN)
{
encrypt_message(message, key);
}
else if (action == DECRYPT_CHOSEN)
{
decrypt_message(message, key);
}
display_result(message, action);
return SUCCESS;
}