blob: 2cc8868c54d14c0a60402210576aca78df56b766 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include <stdio.h>
#include <string.h>
#include "md5.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int main( int argc, char *argv[] )
{
md5 mproc;
md5sum sum;
char hexstr[33];
struct stat s;
stat( argv[1], &s );
char *buf = new char[s.st_size];
FILE *fh = fopen( argv[1], "rb" );
fread( buf, 1, s.st_size, fh );
fclose( fh );
memset( hexstr, 0, 33 );
mproc.sumData( &sum, buf, s.st_size );
mproc.sumToHex( &sum, hexstr );
printf("sum: %s\n", hexstr );
delete[] buf;
return 0;
}
|