Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
fd7bf0fa
Commit
fd7bf0fa
authored
Jan 04, 2011
by
Mark Olesen
Browse files
STYLE: forgot to commit changes to SHA1Digest.C in
e14521b5
parent
25de194d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.C
View file @
fd7bf0fa
...
...
@@ -31,8 +31,8 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
//! @cond fileScope
const
char
hexChars
[]
=
"0123456789abcdef"
;
//! @endcond
fileScope
static
const
char
hexChars
[]
=
"0123456789abcdef"
;
//! @endcond
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
...
...
@@ -87,6 +87,20 @@ void Foam::SHA1Digest::clear()
}
bool
Foam
::
SHA1Digest
::
empty
()
const
{
for
(
unsigned
i
=
0
;
i
<
length
;
++
i
)
{
if
(
v_
[
i
])
{
return
false
;
}
}
return
true
;
}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
bool
Foam
::
SHA1Digest
::
operator
==
(
const
SHA1Digest
&
rhs
)
const
...
...
@@ -103,9 +117,79 @@ bool Foam::SHA1Digest::operator==(const SHA1Digest& rhs) const
}
bool
Foam
::
SHA1Digest
::
operator
==
(
const
std
::
string
&
hexdigits
)
const
{
// null or empty string is not an error - interpret as '0000..'
if
(
hexdigits
.
empty
())
{
return
empty
();
}
// incorrect length - can never match
if
(
hexdigits
.
size
()
!=
length
*
2
)
{
return
false
;
}
for
(
unsigned
i
=
0
,
charI
=
0
;
i
<
length
;
++
i
,
charI
+=
2
)
{
const
char
c1
=
hexChars
[((
v_
[
i
]
>>
4
)
&
0xF
)];
const
char
c2
=
hexChars
[(
v_
[
i
]
&
0xF
)];
if
(
c1
!=
hexdigits
[
charI
]
||
c2
!=
hexdigits
[
charI
+
1
])
{
return
false
;
}
}
return
true
;
}
bool
Foam
::
SHA1Digest
::
operator
==
(
const
char
*
hexdigits
)
const
{
// null or empty string is not an error - interpret as '0000..'
if
(
!
hexdigits
||
!*
hexdigits
)
{
return
empty
();
}
// incorrect length - can never match
if
(
strlen
(
hexdigits
)
!=
length
*
2
)
{
return
false
;
}
for
(
unsigned
i
=
0
,
charI
=
0
;
i
<
length
;
++
i
,
charI
+=
2
)
{
const
char
c1
=
hexChars
[((
v_
[
i
]
>>
4
)
&
0xF
)];
const
char
c2
=
hexChars
[(
v_
[
i
]
&
0xF
)];
if
(
c1
!=
hexdigits
[
charI
]
||
c2
!=
hexdigits
[
charI
+
1
])
{
return
false
;
}
}
return
true
;
}
bool
Foam
::
SHA1Digest
::
operator
!=
(
const
SHA1Digest
&
rhs
)
const
{
return
!
this
->
operator
==
(
rhs
);
return
!
operator
==
(
rhs
);
}
bool
Foam
::
SHA1Digest
::
operator
!=
(
const
std
::
string
&
rhs
)
const
{
return
!
operator
==
(
rhs
);
}
bool
Foam
::
SHA1Digest
::
operator
!=
(
const
char
*
rhs
)
const
{
return
!
operator
==
(
rhs
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment