Imported Upstream version 2.7
[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     {
19         printf("%s: string key\n", argv[0]);
20         exit(1);
21     }
22
23     if((strlen(argv[1]) > 1020) || (strlen(argv[2]) > 512))
24     {
25         printf("%s: size err\n", argv[0]);
26         exit(1);
27     }
28
29     /* Encrypt */
30     OS_BF_Str(argv[1], output, argv[2], strlen(argv[1]), OS_ENCRYPT);
31
32     /* Decript */
33     OS_BF_Str(output, output2, argv[2], strlen(argv[1]), OS_DECRYPT);
34
35     printf("finished.\n");
36     printf("input: '%s'\n",argv[1]);
37     printf("crpt: ");
38     for(i=0;i <= strlen(argv[1]);i++)
39     {
40         printf("%d", output[i]);
41     }
42     printf("\n");
43     printf("output2: '%s'\n",output2);  
44     return(0);
45 }