[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to calculate MD5 of huge files?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 27 Apr 2010 08:05:01 -0300
> My version of lmd5 has this useful function. It calculates the MD5 of
> an entire file and does so from C code.
Allow me some suggestions for that code:
> const size_t BLOCK_SIZE = 32768;
> unsigned char* buffer;
Use a fixed buffer of size BUFSIZ. No need to malloc anything.
fread buffers data anyway. No need to buffer it more than that.
> fseek(file, 0, SEEK_END);
Just read until fread returns zero. If you want to check for errors,
call ferror at the end.