new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git] / src / os_crypto / blowfish / main.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4
5 #include "bf_op.h"
6
7
8 int main(int argc, char **argv)
9 {
10     int i;
11     char output[1024];
12     char output2[1024];
13
14     memset(output, '\0', 1024);
15     memset(output2, '\0', 1024);
16
17     if (argc < 3) {
18         printf("%s: string key\n", argv[0]);
19         exit(1);
20     }
21
22     if ((strlen(argv[1]) > 1020) || (strlen(argv[2]) > 512)) {
23         printf("%s: size err\n", argv[0]);
24         exit(1);
25     }
26
27     /* Encrypt */
28     OS_BF_Str(argv[1], output, argv[2], strlen(argv[1]), OS_ENCRYPT);
29
30     /* Decrypt */
31     OS_BF_Str(output, output2, argv[2], strlen(argv[1]), OS_DECRYPT);
32
33     printf("finished.\n");
34     printf("input: '%s'\n", argv[1]);
35     printf("crpt: ");
36     for (i = 0; i <= strlen(argv[1]); i++) {
37         printf("%d", output[i]);
38     }
39     printf("\n");
40     printf("output2: '%s'\n", output2);
41     return (0);
42 }
43