-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
51 lines (34 loc) · 1.14 KB
/
main.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
/* Copyright (c) 2021-2022, Vaino Kauppila
* All rights reserved
*
* This file is part of the program "c-pass" and use in source and
* binary forms, with or without modification, are permitted exclusively
* under the terms of the GNU Public License v3.0. You should have received
* a copy of the license with this file. If not, please or visit:
* https://www.gnu.org/licenses/gpl-3.0.en.html
*/
#include <stdio.h>
#include <string.h>
#include "enc.h"
int main(int argc, char **argv) {
printf("%d\n", argc);
if (argc != 3) {
printf("not enough arguments\n");
return 1;
}
if (sodium_init() != 0) {
printf("error initializing libsodium\n");
}
char *opt = argv[1];
if (!strcmp(opt, "e")) {
printf("encrypting file 'testencrypt'\n");
encrypt_file("testencrypt", argv[2], "testencrypt.o");
} else if (!strcmp(opt, "d")) {
printf("decrypt the file 'testencrypt'\n");
char *decrypted;
decrypted = decrypt_mem("testencrypt.o", argv[2]);
printf("%s\n", decrypted);
} else {
printf("failure arguments\n");
}
}