changeset 36:dbc1c9ca0030

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 03 Jul 2015 10:01:23 +0200
parents 7c6cf09d838b
children 64ce5bb00a56
files Orthanc/Core/Toolbox.cpp Orthanc/Core/Toolbox.h
diffstat 2 files changed, 22 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Orthanc/Core/Toolbox.cpp	Tue Jun 30 11:55:34 2015 +0200
+++ b/Orthanc/Core/Toolbox.cpp	Fri Jul 03 10:01:23 2015 +0200
@@ -683,15 +683,16 @@
             digest[4]);
   }
 
-  bool Toolbox::IsSHA1(const std::string& str)
+  bool Toolbox::IsSHA1(const char* str,
+                       size_t size)
   {
-    if (str.size() == 0)
+    if (size == 0)
     {
       return false;
     }
 
-    const char* start = &str[0];
-    const char* end = start + str.size();
+    const char* start = str;
+    const char* end = str + size;
 
     // Trim the beginning of the string
     while (start < end)
@@ -747,6 +748,19 @@
   }
 
 
+  bool Toolbox::IsSHA1(const std::string& s)
+  {
+    if (s.size() == 0)
+    {
+      return false;
+    }
+    else
+    {
+      return IsSHA1(s.c_str(), s.size());
+    }
+  }
+
+
 #if BOOST_HAS_DATE_TIME == 1
   std::string Toolbox::GetNowIsoString()
   {
--- a/Orthanc/Core/Toolbox.h	Tue Jun 30 11:55:34 2015 +0200
+++ b/Orthanc/Core/Toolbox.h	Fri Jul 03 10:01:23 2015 +0200
@@ -100,7 +100,10 @@
     void ComputeSHA1(std::string& result,
                      const std::string& data);
 
-    bool IsSHA1(const std::string& str);
+    bool IsSHA1(const char* str,
+                size_t size);
+
+    bool IsSHA1(const std::string& s);
 
     void DecodeBase64(std::string& result, 
                       const std::string& data);