md5-test.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #include "squid.h"
10 #include "md5.h"
11 
12 static void MDPrint(unsigned char digest[16]);
13 static void MDString(char *string);
14 
15 static void
16 MDString(char *string)
17 {
18  MD5_CTX context;
19  unsigned char digest[16];
20  unsigned int len = strlen(string);
21  xMD5Init(&context);
22  xMD5Update(&context, string, len);
23  xMD5Final(digest, &context);
24  printf("MD5 (\"%s\") = ", string);
25  MDPrint(digest);
26  printf("\n");
27 }
28 
29 static void
30 MDPrint(unsigned char digest[16])
31 {
32  unsigned int i;
33  for (i = 0; i < 16; i++)
34  printf("%02x", digest[i]);
35 }
36 
37 int
38 main(int argc, char **argv)
39 {
40  printf("MD5 test suite:\n");
41  MDString("");
42  MDString("a");
43  MDString("abc");
44  MDString("message digest");
45  MDString("abcdefghijklmnopqrstuvwxyz");
46  MDString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
47  MDString("1234567890123456789012345678901234567890"
48  "1234567890123456789012345678901234567890");
49  return 0;
50 }
51 
int i
Definition: membanger.c:49
static void MDPrint(unsigned char digest[16])
Definition: md5-test.c:30
int main(int argc, char **argv)
Definition: md5-test.c:38
int unsigned int const char *desc STUB void int len
Definition: stub_fd.cc:20
static void MDString(char *string)
Definition: md5-test.c:16

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors