diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-09-24 23:49:53 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-09-24 23:49:53 +0100 |
| commit | 4fd257106009b2db170dafddece06ee3c190fceb (patch) | |
| tree | 7c76eb39f2981e4d492404dcc0966de10eb83eb3 /src/lib/util.cc | |
| parent | 45698c6bc5cd3a596e7f0c963733d502c11dd854 (diff) | |
Remove long-since disused hash debugging.
Diffstat (limited to 'src/lib/util.cc')
| -rw-r--r-- | src/lib/util.cc | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc index 73222083a..c779268e2 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -40,6 +40,7 @@ #include <magick/MagickCore.h> #include <magick/version.h> #include <libdcp/version.h> +#include <mhash.h> extern "C" { #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> @@ -61,10 +62,6 @@ extern "C" { #include "player_manager.h" #endif -#ifdef DEBUG_HASH -#include <mhash.h> -#endif - using namespace std; using namespace boost; @@ -347,9 +344,8 @@ split_at_spaces_considering_quotes (string s) return out; } -#ifdef DEBUG_HASH -void -md5_data (string title, void const * data, int size) +string +md5_hash (void const * data, int size) { MHASH ht = mhash_init (MHASH_MD5); if (ht == MHASH_FAILED) { @@ -360,14 +356,16 @@ md5_data (string title, void const * data, int size) uint8_t hash[16]; mhash_deinit (ht, hash); - - printf ("%s [%d]: ", title.c_str (), size); - for (int i = 0; i < int (mhash_get_block_size (MHASH_MD5)); ++i) { - printf ("%.2x", hash[i]); + + int const N = mhash_get_block_size (MHASH_MD5); + stringstream s; + s << hex << setfill('0') << setw(2); + for (int i = 0; i < N; ++i) { + s << ((int) hash[i]); } - printf ("\n"); + + return s.str (); } -#endif /** @param file File name. * @return MD5 digest of file's contents. |
