1 /* Copyright 2014 Clerk Ma
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 #pragma warning(disable:4996)
21 #include "libmd5/md5.h"
23 char * md5_file(const char * file_name)
26 md5_byte_t md5_data[1024];
27 md5_byte_t md5_digest[16];
28 static char md5_hex[33];
33 ship_file = fopen(file_name, "rb");
37 while ((md5_len = fread(md5_data, 1, 1024, ship_file)) != 0)
38 md5_append(&md5_ship, md5_data, md5_len);
40 md5_finish(&md5_ship, md5_digest);
44 for (i = 0; i < 16; ++i)
45 sprintf(md5_hex + i * 2, "%02X", md5_digest[i]);
53 printf("%s", md5_file("md5.c"));