0c7b4a60a81508d509bbaf1c908bff71554c74db kent Fri Sep 5 17:07:58 2014 -0700 Replacing old md5 module with one that follows same interface (except for some things noone used) but that is implemented by calling the md5sum program in a pipe. For large files this is about 40% faster, and for small things it just adds a couple of milliseconds. Also this gets rid of the only piece of GPL licensed code in the tree, which makes the intellecual property easier to manage. diff --git src/inc/md5.h src/inc/md5.h index 4a3c409..e8f1215 100644 --- src/inc/md5.h +++ src/inc/md5.h @@ -1,38 +1,32 @@ +/* md5 calculating functions and the like. Just wrappers for md5sum program */ + #ifndef MD5_H #define MD5_H -#define uint8 unsigned char -#define uint32 unsigned long int -#define uint64 unsigned long long int - -struct md5_context -{ - uint64 total; - uint32 state[4]; - uint8 buffer[64]; -}; +char *md5HexForFile(char * fileName); +/* Calculate md5 on file and return in hex format. Use freeMem on result when done. */ -void md5_starts( struct md5_context *ctx ); -void md5_update( struct md5_context *ctx, uint8 *input, uint32 length ); -void md5_finish( struct md5_context *ctx, uint8 digest[16] ); +char *md5HexForBuf(char *buf, size_t bufSize); +/* Return md5 sum of buffer. Use freeMem on result when done. */ -#define MD5READBUFSIZE 256 * 1024 +char *md5HexForString(char *string); +/* Return md5 sum of zero-terminated string. Use freeMem on result when done. */ void md5ForFile(char * fileName, unsigned char md5[16]); -/* read f in buffer pieces and update md5 hash */ +/* Return MD5 sum for file in md5 in binary rather than hex format. */ -char *md5ToHex(unsigned char md5[16]); -/* return md5 as hex string */ +void md5HexToMd5(char hexIn[32], unsigned char md5Out[16]); +/* Convert hexadecimal representation of md5 back to binary */ -char *md5HexForFile(char * fileName); -/* read f in buffer pieces and return hex string for md5sum */ +char *md5ToHex(unsigned char md5[16]); +/* Convert binary representation of md5 to hex string. Do a freeMem on result when done. */ -char *md5HexForString(char *string); -/* Return hex string for md5sum of string. */ +void md5HexToMd5(char hexIn[32], unsigned char md5Out[16]); +/* Convert hexadecimal representation of md5 back to binary */ struct hash *md5FileHash(char *fileName); /* Read md5sum file and return a hash keyed by file names with md5sum values. */ #endif /* MD5_H */