summaryrefslogtreecommitdiffstats
path: root/Source/cmCryptoHash.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2011-11-16 00:37:38 (GMT)
committerBrad King <brad.king@kitware.com>2011-11-16 15:14:53 (GMT)
commited7cef563445644684af47720c2f7c6fb0a2e440 (patch)
treeb18e93e7293b6592ef0f98c57a493eb8c4ca30c0 /Source/cmCryptoHash.h
parenta9e686d68b5375c471c7204b818fdd2c0a547000 (diff)
downloadCMake-ed7cef563445644684af47720c2f7c6fb0a2e440.zip
CMake-ed7cef563445644684af47720c2f7c6fb0a2e440.tar.gz
CMake-ed7cef563445644684af47720c2f7c6fb0a2e440.tar.bz2
Factor Compute(File|String)MD5 into cmCryptoHash helper
Define an abstract API around the backend hash algorithm. Expose ifstream errors to HashFile callers. Always try opening the file. Succeed only if the end of file is reached without error.
Diffstat (limited to 'Source/cmCryptoHash.h')
-rw-r--r--Source/cmCryptoHash.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h
new file mode 100644
index 0000000..670624c
--- /dev/null
+++ b/Source/cmCryptoHash.h
@@ -0,0 +1,40 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#ifndef cmCryptoHash_h
+#define cmCryptoHash_h
+
+#include "cmStandardIncludes.h"
+
+class cmCryptoHash
+{
+public:
+ std::string HashString(const char* input);
+ std::string HashFile(const char* file);
+protected:
+ virtual void Initialize()=0;
+ virtual void Append(unsigned char const*, int)=0;
+ virtual std::string Finalize()=0;
+};
+
+class cmCryptoHashMD5: public cmCryptoHash
+{
+ struct cmsysMD5_s* MD5;
+public:
+ cmCryptoHashMD5();
+ ~cmCryptoHashMD5();
+protected:
+ virtual void Initialize();
+ virtual void Append(unsigned char const* buf, int sz);
+ virtual std::string Finalize();
+};
+
+#endif