MCPcopy Create free account
hub / github.com/acl-dev/acl / base_test

Function base_test

lib_acl_cpp/samples/md5/main.cpp:8–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include "md5_c.h"
7
8static void base_test(void)
9{
10 const char* s = "���������";
11 const char* key = "zsxxsz";
12 char buf1[33], buf2[33];
13
14 acl::md5::md5_string(s, strlen(s), key, strlen(key),
15 buf1, sizeof(buf1));
16 printf("first md5: %s\r\n", buf1);
17
18 md5_string(s, key, strlen(key), buf2, sizeof(buf2));
19 printf("second md5: %s\r\n", buf2);
20
21 assert(strcmp(buf1, buf2) == 0);
22
23 /////////////////////////////////////////////////////////////////////
24
25 acl::md5 md5;
26
27 s = "ABCDEFGHIGKLMNOPQRSTUVWXYZ";
28 md5.update(s, strlen(s));
29 md5.finish();
30 acl::safe_snprintf(buf1, sizeof(buf1), "%s", md5.get_string());
31
32 md5.reset();
33
34 char ch;
35 size_t len = strlen(s);
36 for (size_t i = 0; i < len; i++) {
37 ch = s[i];
38 md5.update(&ch, 1);
39 }
40 md5.finish();
41 acl::safe_snprintf(buf2, sizeof(buf2), "%s", md5.get_string());
42
43 if (strcmp(buf1, buf2) == 0)
44 printf("OK: %s\r\n", buf1);
45 else
46 printf("error, buf1: %s, buf2: %s\r\n", buf1, buf2);
47
48 /////////////////////////////////////////////////////////////////////
49
50 md5.reset();
51 len = 1024000;
52 char* buf = (char*) malloc(len);
53
54 for (size_t i = 0; i < len; i++) {
55 ch = i % 255;
56 buf[i] = ch;
57 md5.update(&ch, 1);
58 }
59 md5.finish();
60 acl::safe_snprintf(buf1, sizeof(buf1), "%s", md5.get_string());
61
62 md5.reset();
63 md5.update(buf, len);
64 md5.finish();
65 acl::safe_snprintf(buf2, sizeof(buf2), "%s", md5.get_string());

Callers 1

mainFunction · 0.85

Calls 7

md5_stringFunction · 0.85
safe_snprintfFunction · 0.85
mallocFunction · 0.85
updateMethod · 0.45
finishMethod · 0.45
get_stringMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…