Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPlugins.cpp @ 1833:47d032c48818
"OrthancPluginComputeMd5()" and "OrthancPluginComputeSha1()" to compute MD5/SHA-1 hash
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 27 Nov 2015 12:22:44 +0100 |
parents | 31df3b48925e |
children | 859224214616 |
comparison
equal
deleted
inserted
replaced
1832:b7da58699f92 | 1833:47d032c48818 |
---|---|
1493 | 1493 |
1494 CopyToMemoryBuffer(*p.target, dicom); | 1494 CopyToMemoryBuffer(*p.target, dicom); |
1495 } | 1495 } |
1496 | 1496 |
1497 | 1497 |
1498 void OrthancPlugins::ComputeHash(_OrthancPluginService service, | |
1499 const void* parameters) | |
1500 { | |
1501 const _OrthancPluginComputeHash& p = | |
1502 *reinterpret_cast<const _OrthancPluginComputeHash*>(parameters); | |
1503 | |
1504 std::string hash; | |
1505 switch (service) | |
1506 { | |
1507 case _OrthancPluginService_ComputeMd5: | |
1508 Toolbox::ComputeMD5(hash, p.buffer, p.size); | |
1509 break; | |
1510 | |
1511 case _OrthancPluginService_ComputeSha1: | |
1512 Toolbox::ComputeSHA1(hash, p.buffer, p.size); | |
1513 break; | |
1514 | |
1515 default: | |
1516 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
1517 } | |
1518 | |
1519 *p.result = CopyString(hash); | |
1520 } | |
1521 | |
1522 | |
1498 void OrthancPlugins::ApplyCreateImage(_OrthancPluginService service, | 1523 void OrthancPlugins::ApplyCreateImage(_OrthancPluginService service, |
1499 const void* parameters) | 1524 const void* parameters) |
1500 { | 1525 { |
1501 const _OrthancPluginCreateImage& p = | 1526 const _OrthancPluginCreateImage& p = |
1502 *reinterpret_cast<const _OrthancPluginCreateImage*>(parameters); | 1527 *reinterpret_cast<const _OrthancPluginCreateImage*>(parameters); |
2098 case _OrthancPluginService_CreateImageAccessor: | 2123 case _OrthancPluginService_CreateImageAccessor: |
2099 case _OrthancPluginService_DecodeDicomImage: | 2124 case _OrthancPluginService_DecodeDicomImage: |
2100 ApplyCreateImage(service, parameters); | 2125 ApplyCreateImage(service, parameters); |
2101 return true; | 2126 return true; |
2102 | 2127 |
2128 case _OrthancPluginService_ComputeMd5: | |
2129 case _OrthancPluginService_ComputeSha1: | |
2130 ComputeHash(service, parameters); | |
2131 return true; | |
2132 | |
2103 default: | 2133 default: |
2104 { | 2134 { |
2105 // This service is unknown to the Orthanc plugin engine | 2135 // This service is unknown to the Orthanc plugin engine |
2106 return false; | 2136 return false; |
2107 } | 2137 } |