ze-filter  (ze-filter-0.8.0-develop-180218)
ze-crypt-test.c
Go to the documentation of this file.
1 
2 /*
3  *
4  * ze-filter - Mail Server Filter for sendmail
5  *
6  * Copyright (c) 2001-2018 - Jose-Marcio Martins da Cruz
7  *
8  * Auteur : Jose Marcio Martins da Cruz
9  * jose.marcio.mc@gmail.org
10  *
11  * Historique :
12  * Creation : janvier 2002
13  *
14  * This program is free software, but with restricted license :
15  *
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20  *
21  * More details about ze-filter license can be found at ze-filter
22  * web site : http://foss.jose-marcio.org
23  */
24 
25 #include <ze-sys.h>
26 #include <libze.h>
27 #include <libml.h>
28 #include <ze-filter.h>
29 
30 
31 int
32 main(argc, argv)
33  int argc;
34  char **argv;
35 {
36  char *tok[1000000];
37  char sin[256];
38 
39  int i;
40  uint64_t ti, tf;
41 
42  int res = 0;
43  extern int ze_logLevel;
44 
45  memset(tok, 0, sizeof (tok));
46 
47  for (i = 0; i < 1000000 && fgets(sin, sizeof (sin), stdin) != NULL; i++) {
48  if ((tok[i] = strdup(sin)) == NULL)
49  break;
50  }
51  printf(" * %7d tokens read\n", i);
52 
53 
54  ti = zeTime_ms();
55  for (i = 0; i < 1000000 && tok[i] != NULL; i++) {
56  char sout[256];
57 
58  jmc_str2md5(sout, (unsigned char *) tok[i], sizeof (sout));
59 #if 0
60  printf("MD5 %s\n", sout);
61 #endif
62  }
63  tf = zeTime_ms();
64  printf(" * MD5 = %4ld ms elapsed\n", tf - ti);
65 
66  ti = zeTime_ms();
67  for (i = 0; i < 1000000 && tok[i] != NULL; i++) {
68  char sout[256];
69 
70  jmc_str2sha1(sout, (unsigned char *) tok[i], sizeof (sout));
71 #if 0
72  printf("SHA1 %s\n", sout);
73 #endif
74  }
75  tf = zeTime_ms();
76  printf(" * SHA1 = %4d ms elapsed\n", tf - ti);
77 
78  if (0) {
79  char sout[256];
80  char *s;
81 
82  s = "dieochetiz_'";
83  jmc_str2md5(sout, (unsigned char *) s, sizeof (sout));
84  printf("* MD5 %-40s %s\n", s, sout);
85  jmc_str2sha1(sout, (unsigned char *) s, sizeof (sout));
86  printf("* SHA1 %-40s %s\n", s, sout);
87 
88  s = "dkeiu ___-_dffgfskjoieud877546766";
89  jmc_str2md5(sout, (unsigned char *) s, sizeof (sout));
90  printf("* MD5 %-40s %s\n", s, sout);
91  jmc_str2sha1(sout, (unsigned char *) s, sizeof (sout));
92  printf("* SHA1 %-40s %s\n", s, sout);
93  }
94 
95  return 0;
96 }
bool jmc_str2sha1(char *sout, unsigned char *sin, size_t szout)
Definition: ze-msg-hash.c:60
uint64_t zeTime_ms()
Definition: zeTime.c:34
int ze_logLevel
Definition: zeSyslog.c:34
int main(int argc, char **argv)
Definition: ze-crypt-test.c:32
bool jmc_str2md5(char *sout, unsigned char *sin, size_t szout)
Definition: ze-msg-hash.c:37