diff Core/Toolbox.cpp @ 402:d2c69150a979

bulk storescu
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 30 Apr 2013 11:50:51 +0200
parents bdd72233b105
children 30086c1aca30
line wrap: on
line diff
--- a/Core/Toolbox.cpp	Tue Apr 30 10:57:00 2013 +0200
+++ b/Core/Toolbox.cpp	Tue Apr 30 11:50:51 2013 +0200
@@ -565,6 +565,33 @@
     }
   }
 
+  bool Toolbox::IsSHA1(const std::string& str)
+  {
+    if (str.size() != 44)
+    {
+      return false;
+    }
+
+    for (unsigned int i = 0; i < 44; i++)
+    {
+      if (i == 8 ||
+          i == 17 ||
+          i == 26 ||
+          i == 35)
+      {
+        if (str[i] != '-')
+          return false;
+      }
+      else
+      {
+        if (!isalnum(str[i]))
+          return false;
+      }
+    }
+
+    return true;
+  }
+
   std::string Toolbox::GetNowIsoString()
   {
     boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();