Mercurial > hg > orthanc
comparison OrthancFramework/Sources/Toolbox.cpp @ 5806:16df20505710 default
fix build for boost 1.86
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 24 Sep 2024 09:26:42 +0200 |
parents | e4d9a872998f |
children |
comparison
equal
deleted
inserted
replaced
5800:2854418a7c0d | 5806:16df20505710 |
---|---|
799 } | 799 } |
800 | 800 |
801 return result; | 801 return result; |
802 } | 802 } |
803 | 803 |
804 | |
805 void Toolbox::ComputeSHA1(std::string& result, | 804 void Toolbox::ComputeSHA1(std::string& result, |
806 const void* data, | 805 const void* data, |
807 size_t size) | 806 size_t size) |
808 { | 807 { |
809 boost::uuids::detail::sha1 sha1; | 808 boost::uuids::detail::sha1 sha1; |
812 { | 811 { |
813 sha1.process_bytes(data, size); | 812 sha1.process_bytes(data, size); |
814 } | 813 } |
815 | 814 |
816 unsigned int digest[5]; | 815 unsigned int digest[5]; |
817 | |
818 // Sanity check for the memory layout: A SHA-1 digest is 160 bits wide | 816 // Sanity check for the memory layout: A SHA-1 digest is 160 bits wide |
819 assert(sizeof(unsigned int) == 4 && sizeof(digest) == (160 / 8)); | 817 assert(sizeof(unsigned int) == 4 && sizeof(digest) == (160 / 8)); |
818 assert(sizeof(boost::uuids::detail::sha1::digest_type) == 20); | |
820 | 819 |
821 sha1.get_digest(digest); | 820 // From Boost 1.86, digest_type is "unsigned char[20]" while it was "unsigned int[5]"" in previous versions. |
821 // Always perform the cast even if it is useless for Boost < 1.86 | |
822 sha1.get_digest(*(reinterpret_cast<boost::uuids::detail::sha1::digest_type*>(digest))); | |
822 | 823 |
823 result.resize(8 * 5 + 4); | 824 result.resize(8 * 5 + 4); |
824 sprintf(&result[0], "%08x-%08x-%08x-%08x-%08x", | 825 sprintf(&result[0], "%08x-%08x-%08x-%08x-%08x", |
825 digest[0], | 826 digest[0], |
826 digest[1], | 827 digest[1], |