Upload Tizen:Base source
[framework/base/util-linux-ng.git] / tests / helpers / test_md5.c
1
2 #include <stdio.h>
3 #include <unistd.h>
4
5 #include "md5.h"
6
7 int
8 main(int argc, char *argv[])
9 {
10         int i, ret;
11         struct MD5Context ctx;
12         unsigned char digest[16];
13         unsigned char buf[BUFSIZ];
14
15         MD5Init( &ctx );
16
17         while(!feof(stdin) && !ferror(stdin)) {
18                 ret = fread(buf, 1, sizeof(buf), stdin);
19                 if (ret)
20                         MD5Update( &ctx, buf, ret );
21         }
22
23         fclose(stdin);
24         MD5Final( digest, &ctx );
25
26         for (i = 0; i < 16; i++)
27                 printf( "%02x", digest[i] );
28         printf("  -\n");
29         return 0;
30 }