diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index 7f4b10fbc..0d3c6bbcb 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -35,18 +35,18 @@ cmsys::auto_ptr cmCryptoHash::New(const char* algo) } //---------------------------------------------------------------------------- -std::string cmCryptoHash::HashString(const char* input) +std::string cmCryptoHash::HashString(const std::string& input) { this->Initialize(); - this->Append(reinterpret_cast(input), - static_cast(strlen(input))); + this->Append(reinterpret_cast(&input[0]), + static_cast(input.size())); return this->Finalize(); } //---------------------------------------------------------------------------- -std::string cmCryptoHash::HashFile(const char* file) +std::string cmCryptoHash::HashFile(const std::string& file) { - cmsys::ifstream fin(file, std::ios::in | cmsys_ios_binary); + cmsys::ifstream fin(file.c_str(), std::ios::in | cmsys_ios_binary); if(!fin) { return ""; diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h index 1bea9abcb..88cd240c0 100644 --- a/Source/cmCryptoHash.h +++ b/Source/cmCryptoHash.h @@ -21,8 +21,8 @@ class cmCryptoHash public: virtual ~cmCryptoHash() {} static cmsys::auto_ptr New(const char* algo); - std::string HashString(const char* input); - std::string HashFile(const char* file); + std::string HashString(const std::string& input); + std::string HashFile(const std::string& file); protected: virtual void Initialize()=0; virtual void Append(unsigned char const*, int)=0; diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 7cc63bbdf..18eb62e21 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -944,7 +944,7 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname) #endif } -bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out) +bool cmSystemTools::ComputeFileMD5(const std::string& source, char* md5out) { #if defined(CMAKE_BUILD_WITH_CMAKE) cmCryptoHashMD5 md5; @@ -959,7 +959,7 @@ bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out) #endif } -std::string cmSystemTools::ComputeStringMD5(const char* input) +std::string cmSystemTools::ComputeStringMD5(const std::string& input) { #if defined(CMAKE_BUILD_WITH_CMAKE) cmCryptoHashMD5 md5; diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 4a5d2981b..da37cebae 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -185,10 +185,10 @@ public: static bool RenameFile(const char* oldname, const char* newname); ///! Compute the md5sum of a file - static bool ComputeFileMD5(const char* source, char* md5out); + static bool ComputeFileMD5(const std::string& source, char* md5out); /** Compute the md5sum of a string. */ - static std::string ComputeStringMD5(const char* input); + static std::string ComputeStringMD5(const std::string& input); /** * Run a single executable command