2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
9 * $Id: md5hl.c,v 1.8.2.1 1998/02/18 02:24:05 jkh Exp $
13 #include <sys/types.h>
27 MD5End(MD5_CTX
*ctx
, char *buf
)
30 unsigned char digest
[MD5_HASHBYTES
];
31 static const char hex
[]="0123456789abcdef";
38 for (i
=0;i
<MD5_HASHBYTES
;i
++) {
39 buf
[i
+i
] = hex
[digest
[i
] >> 4];
40 buf
[i
+i
+1] = hex
[digest
[i
] & 0x0f];
47 MD5File (const char *filename
, char *buf
)
49 unsigned char buffer
[BUFSIZ
];
57 if (!(f
= fopen(filename
, "r")))
59 printf("%s\n", filename
);for(;;);
60 if (fopen_s(&f
, filename
, "r") != 0) /* tady to hnije .. */
63 while ((i
= fread(buffer
,sizeof buffer
,1,f
)) > 0) {
64 MD5Update(&ctx
,buffer
,i
);
70 return MD5End(&ctx
, buf
);
74 MD5Data (const unsigned char *data
, unsigned int len
, char *buf
)
79 MD5Update(&ctx
,data
,len
);
80 return MD5End(&ctx
, buf
);