Mercurial > hg > orthanc
diff Core/Toolbox.cpp @ 577:2737806bcf60 laaw
integration mainline->laaw
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 30 Sep 2013 15:03:36 +0200 |
parents | 86c5bb651bfa 69c024f9c06b |
children | b82292ba2083 0bedf8ff9288 |
line wrap: on
line diff
--- a/Core/Toolbox.cpp Mon Sep 30 13:54:32 2013 +0200 +++ b/Core/Toolbox.cpp Mon Sep 30 15:03:36 2013 +0200 @@ -39,6 +39,7 @@ #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> #include <boost/date_time/posix_time/posix_time.hpp> +#include <boost/uuid/sha1.hpp> #include <algorithm> #include <ctype.h> @@ -65,7 +66,6 @@ #include "../Resources/md5/md5.h" #include "../Resources/base64/base64.h" -#include "../Resources/sha1/sha1.h" #ifdef _MSC_VER @@ -572,31 +572,27 @@ void Toolbox::ComputeSHA1(std::string& result, const std::string& data) { - SHA1 sha1; + boost::uuids::detail::sha1 sha1; + if (data.size() > 0) { - sha1.Input(&data[0], data.size()); + sha1.process_bytes(&data[0], data.size()); } - unsigned digest[5]; + unsigned int digest[5]; // Sanity check for the memory layout: A SHA-1 digest is 160 bits wide - assert(sizeof(unsigned) == 4 && sizeof(digest) == (160 / 8)); + assert(sizeof(unsigned int) == 4 && sizeof(digest) == (160 / 8)); - if (sha1.Result(digest)) - { - result.resize(8 * 5 + 4); - sprintf(&result[0], "%08x-%08x-%08x-%08x-%08x", - digest[0], - digest[1], - digest[2], - digest[3], - digest[4]); - } - else - { - throw OrthancException(ErrorCode_InternalError); - } + sha1.get_digest(digest); + + result.resize(8 * 5 + 4); + sprintf(&result[0], "%08x-%08x-%08x-%08x-%08x", + digest[0], + digest[1], + digest[2], + digest[3], + digest[4]); } bool Toolbox::IsSHA1(const std::string& str)