comparison Core/Toolbox.cpp @ 560:69c024f9c06b

fix of Debian bug #724947
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 30 Sep 2013 14:42:01 +0200
parents 8c3573d28868
children 2737806bcf60
comparison
equal deleted inserted replaced
557:48c9f83587a8 560:69c024f9c06b
37 #include <stdint.h> 37 #include <stdint.h>
38 #include <string.h> 38 #include <string.h>
39 #include <boost/filesystem.hpp> 39 #include <boost/filesystem.hpp>
40 #include <boost/filesystem/fstream.hpp> 40 #include <boost/filesystem/fstream.hpp>
41 #include <boost/date_time/posix_time/posix_time.hpp> 41 #include <boost/date_time/posix_time/posix_time.hpp>
42 #include <boost/uuid/sha1.hpp>
42 #include <algorithm> 43 #include <algorithm>
43 #include <ctype.h> 44 #include <ctype.h>
44 45
45 #if defined(_WIN32) 46 #if defined(_WIN32)
46 #include <windows.h> 47 #include <windows.h>
63 #include <iconv.h> 64 #include <iconv.h>
64 #endif 65 #endif
65 66
66 #include "../Resources/md5/md5.h" 67 #include "../Resources/md5/md5.h"
67 #include "../Resources/base64/base64.h" 68 #include "../Resources/base64/base64.h"
68 #include "../Resources/sha1/sha1.h"
69 69
70 70
71 #if BOOST_HAS_LOCALE == 0 71 #if BOOST_HAS_LOCALE == 0
72 namespace 72 namespace
73 { 73 {
557 } 557 }
558 558
559 void Toolbox::ComputeSHA1(std::string& result, 559 void Toolbox::ComputeSHA1(std::string& result,
560 const std::string& data) 560 const std::string& data)
561 { 561 {
562 SHA1 sha1; 562 boost::uuids::detail::sha1 sha1;
563
563 if (data.size() > 0) 564 if (data.size() > 0)
564 { 565 {
565 sha1.Input(&data[0], data.size()); 566 sha1.process_bytes(&data[0], data.size());
566 } 567 }
567 568
568 unsigned digest[5]; 569 unsigned int digest[5];
569 570
570 // Sanity check for the memory layout: A SHA-1 digest is 160 bits wide 571 // Sanity check for the memory layout: A SHA-1 digest is 160 bits wide
571 assert(sizeof(unsigned) == 4 && sizeof(digest) == (160 / 8)); 572 assert(sizeof(unsigned int) == 4 && sizeof(digest) == (160 / 8));
572 573
573 if (sha1.Result(digest)) 574 sha1.get_digest(digest);
574 { 575
575 result.resize(8 * 5 + 4); 576 result.resize(8 * 5 + 4);
576 sprintf(&result[0], "%08x-%08x-%08x-%08x-%08x", 577 sprintf(&result[0], "%08x-%08x-%08x-%08x-%08x",
577 digest[0], 578 digest[0],
578 digest[1], 579 digest[1],
579 digest[2], 580 digest[2],
580 digest[3], 581 digest[3],
581 digest[4]); 582 digest[4]);
582 }
583 else
584 {
585 throw OrthancException(ErrorCode_InternalError);
586 }
587 } 583 }
588 584
589 bool Toolbox::IsSHA1(const std::string& str) 585 bool Toolbox::IsSHA1(const std::string& str)
590 { 586 {
591 if (str.size() != 44) 587 if (str.size() != 44)