Use openssl for all MD5-ing.
authorCarl Hetherington <cth@carlh.net>
Mon, 24 Sep 2012 23:27:14 +0000 (00:27 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 24 Sep 2012 23:27:14 +0000 (00:27 +0100)
src/lib/util.cc
src/lib/wscript
src/wscript

index c779268e2b338423c3454969c682b0df4ac39fff..935566440276f563ba5adcb86c44075c06eb5fa7 100644 (file)
@@ -40,7 +40,6 @@
 #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>
@@ -345,23 +344,17 @@ split_at_spaces_considering_quotes (string s)
 }
 
 string
-md5_hash (void const * data, int size)
+md5_digest (void const * data, int size)
 {
-       MHASH ht = mhash_init (MHASH_MD5);
-       if (ht == MHASH_FAILED) {
-               throw EncodeError ("could not create hash thread");
-       }
-
-       mhash (ht, data, size);
+       MD5_CTX md5_context;
+       MD5_Init (&md5_context);
+       MD5_Update (&md5_context, data, size);
+       unsigned char digest[MD5_DIGEST_LENGTH];
+       MD5_Final (digest, &md5_context);
        
-       uint8_t hash[16];
-       mhash_deinit (ht, hash);
-
-       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]);
+       for (int i = 0; i < MD5_DIGEST_LENGTH; ++i) {
+               s << hex << setfill('0') << setw(2) << ((int) digest[i]);
        }
 
        return s.str ();
index 26740a7e9164570c5c4893704999c37a64069009..803ffd9ee058e40a77bd62d1309be91ca19e49a8 100644 (file)
@@ -1,11 +1,8 @@
-def configure(conf):
-    conf.check_cc(msg = 'Checking for library libmhash', function_name = 'mhash_init', header_name = 'mhash.h', lib = 'mhash', uselib_store = 'MHASH')
-
 def build(bld):
     obj = bld(features = 'cxx cxxshlib')
     obj.name = 'libdvdomatic'
     obj.export_includes = ['.']
-    obj.uselib = 'AVCODEC AVUTIL AVFORMAT AVFILTER SWSCALE SWRESAMPLE SNDFILE BOOST_FILESYSTEM BOOST_THREAD OPENJPEG POSTPROC TIFF SIGC++ MAGICK SSH DCP GLIB MHASH'
+    obj.uselib = 'AVCODEC AVUTIL AVFORMAT AVFILTER SWSCALE SWRESAMPLE SNDFILE BOOST_FILESYSTEM BOOST_THREAD OPENJPEG POSTPROC TIFF SIGC++ MAGICK SSH DCP GLIB'
     if bld.env.TARGET_WINDOWS:
         obj.uselib += ' WINSOCK2'
     obj.source = """
index 2ebeba210d12bfc349e0af062c79af28dd38c6d0..3f17b3e6ce026106366bca7733169797f46378bd 100644 (file)
@@ -1,5 +1,4 @@
 def configure(conf):
-    conf.recurse('lib')
     if not conf.env.DISABLE_GUI:
         conf.recurse('wx')