diff --git a/applications/test/sha1/Test-SHA1.C b/applications/test/sha1/Test-SHA1.C index 70dc0c0f54..e87e12a220 100644 --- a/applications/test/sha1/Test-SHA1.C +++ b/applications/test/sha1/Test-SHA1.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2015 OpenFOAM Foundation @@ -24,11 +24,10 @@ License along with OpenFOAM. If not, see . Application - testSHA1 + Test-SHA1 Description - \*---------------------------------------------------------------------------*/ #include "OSHA1stream.H" @@ -42,15 +41,27 @@ using namespace Foam; int main(int argc, char * argv[]) { SHA1 sha; + OSHA1stream osha; SHA1Digest shaDig; const std::string str("The quick brown fox jumps over the lazy dog"); Info<< shaDig << " : empty" << nl; Info<< SHA1(str) << " : " << str << nl; + Info<< osha.digest() << " : empty" << nl; + + osha<< ""; + Info<< osha.digest() << " : still empty" << nl; + + osha<< std::string(); + Info<< osha.digest() << " : still empty" << nl; + sha.append(str); Info<< sha << " : appended to empty" << nl; + osha<< str; + Info<< osha.digest() << " : output << to empty" << nl; + sha.clear(); sha.append(str); shaDig = sha; diff --git a/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H b/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H index f4a622e6cf..e28034dc0c 100644 --- a/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H +++ b/src/OpenFOAM/db/IOstreams/hashes/OSHA1stream.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011 OpenFOAM Foundation @@ -211,6 +211,16 @@ public: {} + // Write Functions + + //- Add (unquoted) string contents. + // Ensures that SHA1 of C-string or C++-string content are identical. + virtual Ostream& write(const string& str) + { + return writeQuoted(str, false); // Unquoted! + } + + // Housekeeping //- Deprecated(2017-07) clear the SHA1 calculation