SHA1I.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011 OpenFOAM Foundation
9 Copyright (C) 2019-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30
32{
33 clear();
34}
35
36
37inline Foam::SHA1::SHA1(const char* str)
38{
39 clear();
40 append(str);
41}
42
43
44inline Foam::SHA1::SHA1(const std::string& str)
45{
46 clear();
47 append(str);
48}
49
50
51// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
52
53inline void Foam::SHA1::append(char c)
54{
55 processBytes(&c, 1);
56}
57
58
59inline void Foam::SHA1::append(const char* data, size_t len)
60{
61 processBytes(data, len);
62}
63
64
65inline void Foam::SHA1::append(const char* str)
66{
67 if (str && *str)
68 {
69 processBytes(str, std::char_traits<char>::length(str));
70 }
71}
72
73
74inline void Foam::SHA1::append(const std::string& str)
75{
76 processBytes(str.data(), str.length());
77}
78
79
81(
82 const std::string& str,
83 size_t pos,
84 size_t len
85)
86{
87 if (std::string::npos != pos && pos < str.length())
88 {
89 if (std::string::npos == len || pos + len > str.length())
90 {
91 len = str.length() - pos;
92 }
93
94 processBytes(str.data() + pos, len);
95 }
96}
97
98
100{
101 SHA1Digest dig;
102
103 if (finalized_)
104 {
105 calcDigest(dig);
106 }
107 else
108 {
109 // Avoid disturbing current data - use a copy
110 SHA1 sha(*this);
111 if (sha.finalize())
112 {
113 sha.calcDigest(dig);
114 }
115 }
116
117 return dig;
118}
119
120
121inline std::string Foam::SHA1::str(const bool prefixed) const
122{
123 return digest().str(prefixed);
124}
125
126
127inline Foam::Ostream& Foam::SHA1::write(Ostream& os, const bool prefixed) const
128{
129 return digest().write(os, prefixed);
130}
131
132
133// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
134
136{
137 return digest();
138}
139
140
141inline bool Foam::SHA1::operator==(const SHA1& rhs) const
142{
143 return this->digest() == rhs.digest();
144}
145
146
147inline bool Foam::SHA1::operator==(const SHA1Digest& dig) const
148{
149 return this->digest() == dig;
150}
151
152
153inline bool Foam::SHA1::operator==(const std::string& hexdigits) const
154{
155 return this->digest() == hexdigits;
156}
157
158
159inline bool Foam::SHA1::operator==(const char* hexdigits) const
160{
161 return this->digest() == hexdigits;
162}
163
164
165inline bool Foam::SHA1::operator!=(const SHA1& rhs) const
166{
167 return !this->operator==(rhs);
168}
169
170
171inline bool Foam::SHA1::operator!=(const SHA1Digest& rhs) const
172{
173 return !this->operator==(rhs);
174}
175
176
177inline bool Foam::SHA1::operator!=(const std::string& hexdigits) const
178{
179 return !this->operator==(hexdigits);
180}
181
182
183inline bool Foam::SHA1::operator!=(const char* hexdigits) const
184{
185 return !this->operator==(hexdigits);
186}
187
188
189// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
190
192{
193 return sha.write(os);
194}
195
196
197// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
The SHA1 message digest.
Definition: SHA1Digest.H:61
Functions to compute SHA1 message digest according to the NIST specification FIPS-180-1.
Definition: SHA1.H:61
void clear() noexcept
Reset the hashed data before appending more.
Definition: SHA1.C:315
bool finalize()
Finalized the calculations (normally not needed directly).
Definition: SHA1.C:330
Ostream & write(Ostream &os, const bool prefixed=false) const
Write digest (40-byte) representation, optionally with '_' prefix.
Definition: SHA1I.H:127
SHA1()
Default construct.
Definition: SHA1I.H:31
SHA1Digest digest() const
Calculate digest from current data.
Definition: SHA1I.H:99
Database for solution data, solver performance and other reduced data.
Definition: data.H:58
friend Ostream & operator(Ostream &, const faMatrix< Type > &)
virtual bool write()
Write the output fields.
friend bool operator!=(const refineCell &rc1, const refineCell &rc2)
Definition: refineCell.H:106
friend bool operator==(const refineCell &rc1, const refineCell &rc2)
Definition: refineCell.H:97
const word & str() const
The string representation of the volume type enumeration.
Definition: volumeType.C:62
bool append() const noexcept
True if output format uses an append mode.
patchWriters clear()
OBJstream os(runTime.globalPath()/outputName)
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
dimensionedScalar pos(const dimensionedScalar &ds)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)