Mercurial > hg > orthanc
diff Core/Toolbox.cpp @ 693:01d8611c4a60
md5 for attached files
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 04 Feb 2014 17:52:51 +0100 |
parents | 2e67366aab83 |
children | 203157cb4fde |
line wrap: on
line diff
--- a/Core/Toolbox.cpp Tue Feb 04 16:57:34 2014 +0100 +++ b/Core/Toolbox.cpp Tue Feb 04 17:52:51 2014 +0100 @@ -465,13 +465,29 @@ void Toolbox::ComputeMD5(std::string& result, const std::string& data) { + if (data.size() > 0) + { + ComputeMD5(result, &data[0], data.size()); + } + else + { + ComputeMD5(result, NULL, 0); + } + } + + + void Toolbox::ComputeMD5(std::string& result, + const void* data, + size_t length) + { md5_state_s state; md5_init(&state); - if (data.size() > 0) + if (length > 0) { - md5_append(&state, reinterpret_cast<const md5_byte_t*>(&data[0]), - static_cast<int>(data.size())); + md5_append(&state, + reinterpret_cast<const md5_byte_t*>(data), + static_cast<int>(length)); } md5_byte_t actualHash[16];