Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
692:1a3f9d90a2dd | 693:01d8611c4a60 |
---|---|
463 | 463 |
464 | 464 |
465 void Toolbox::ComputeMD5(std::string& result, | 465 void Toolbox::ComputeMD5(std::string& result, |
466 const std::string& data) | 466 const std::string& data) |
467 { | 467 { |
468 if (data.size() > 0) | |
469 { | |
470 ComputeMD5(result, &data[0], data.size()); | |
471 } | |
472 else | |
473 { | |
474 ComputeMD5(result, NULL, 0); | |
475 } | |
476 } | |
477 | |
478 | |
479 void Toolbox::ComputeMD5(std::string& result, | |
480 const void* data, | |
481 size_t length) | |
482 { | |
468 md5_state_s state; | 483 md5_state_s state; |
469 md5_init(&state); | 484 md5_init(&state); |
470 | 485 |
471 if (data.size() > 0) | 486 if (length > 0) |
472 { | 487 { |
473 md5_append(&state, reinterpret_cast<const md5_byte_t*>(&data[0]), | 488 md5_append(&state, |
474 static_cast<int>(data.size())); | 489 reinterpret_cast<const md5_byte_t*>(data), |
490 static_cast<int>(length)); | |
475 } | 491 } |
476 | 492 |
477 md5_byte_t actualHash[16]; | 493 md5_byte_t actualHash[16]; |
478 md5_finish(&state, actualHash); | 494 md5_finish(&state, actualHash); |
479 | 495 |