SHA1 Class Reference

Functions to compute SHA1 message digest according to the NIST specification FIPS-180-1. More...

Public Member Functions

 SHA1 ()
 Default construct. More...
 
 SHA1 (const char *str)
 Default construct and append initial string content. More...
 
 SHA1 (const std::string &str)
 Default construct and append initial string content. More...
 
void clear () noexcept
 Reset the hashed data before appending more. More...
 
void append (char c)
 Append single character. More...
 
void append (const char *str)
 Append string for processing. More...
 
void append (const char *data, size_t len)
 Append data for processing. More...
 
void append (const std::string &str)
 Append string for processing. More...
 
void append (const std::string &str, size_t pos, size_t len=std::string::npos)
 Append substring for processing. More...
 
bool finalize ()
 Finalized the calculations (normally not needed directly). More...
 
SHA1Digest digest () const
 Calculate digest from current data. More...
 
std::string str (const bool prefixed=false) const
 The digest (40-byte) text representation, optionally with '_' prefix. More...
 
Ostreamwrite (Ostream &os, const bool prefixed=false) const
 Write digest (40-byte) representation, optionally with '_' prefix. More...
 
 operator SHA1Digest () const
 Cast conversion to a SHA1Digest,. More...
 
bool operator== (const SHA1 &rhs) const
 Equality operator, compares digests. More...
 
bool operator== (const SHA1Digest &dig) const
 Compare digest. More...
 
bool operator== (const std::string &hexdigits) const
 Compare digest to (40-byte) text representation (eg, from sha1sum) More...
 
bool operator== (const char *hexdigits) const
 Compare digest to (40-byte) text representation (eg, from sha1sum) More...
 
bool operator!= (const SHA1 &) const
 Inequality operator, compares digests. More...
 
bool operator!= (const SHA1Digest &) const
 Inequality operator, compare digest. More...
 
bool operator!= (const std::string &hexdigits) const
 Inequality operator, compares digests. More...
 
bool operator!= (const char *hexdigits) const
 Inequality operator, compare digest. More...
 

Detailed Description

Functions to compute SHA1 message digest according to the NIST specification FIPS-180-1.

Adapted from the gnulib implementation.

See also
Foam::SHA1Digest
Source files

Definition at line 60 of file SHA1.H.

Constructor & Destructor Documentation

◆ SHA1() [1/3]

SHA1 ( )
inline

Default construct.

Definition at line 31 of file SHA1I.H.

References SHA1::clear().

Here is the call graph for this function:

◆ SHA1() [2/3]

SHA1 ( const char *  str)
inlineexplicit

Default construct and append initial string content.

Definition at line 37 of file SHA1I.H.

References append(), and clear().

Here is the call graph for this function:

◆ SHA1() [3/3]

SHA1 ( const std::string &  str)
inlineexplicit

Default construct and append initial string content.

Definition at line 44 of file SHA1I.H.

References append(), and clear().

Here is the call graph for this function:

Member Function Documentation

◆ clear()

void clear ( )
noexcept

Reset the hashed data before appending more.

Definition at line 315 of file SHA1.C.

Referenced by OSHA1streamAllocator::reset(), and SHA1::SHA1().

Here is the caller graph for this function:

◆ append() [1/5]

void append ( char  c)
inline

Append single character.

Definition at line 53 of file SHA1I.H.

Referenced by dynamicCodeContext::append().

Here is the caller graph for this function:

◆ append() [2/5]

void append ( const char *  str)
inline

Append string for processing.

Definition at line 65 of file SHA1I.H.

◆ append() [3/5]

void append ( const char *  data,
size_t  len 
)
inline

Append data for processing.

Definition at line 59 of file SHA1I.H.

◆ append() [4/5]

void append ( const std::string &  str)
inline

Append string for processing.

Definition at line 74 of file SHA1I.H.

◆ append() [5/5]

void append ( const std::string &  str,
size_t  pos,
size_t  len = std::string::npos 
)
inline

Append substring for processing.

Definition at line 80 of file SHA1I.H.

References Foam::pos().

Here is the call graph for this function:

◆ finalize()

bool finalize ( )

Finalized the calculations (normally not needed directly).

Returns false if no bytes were passed for processing

Definition at line 330 of file SHA1.C.

Referenced by SHA1::digest().

Here is the caller graph for this function:

◆ digest()

Foam::SHA1Digest digest ( ) const
inline

Calculate digest from current data.

Definition at line 99 of file SHA1I.H.

References SHA1::finalize().

Referenced by OSHA1streamAllocator::digest(), and SHA1::operator==().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ str()

std::string str ( const bool  prefixed = false) const
inline

The digest (40-byte) text representation, optionally with '_' prefix.

Definition at line 121 of file SHA1I.H.

Referenced by codeStream::getFunction(), dynamicCode::setFilterContext(), and codedBase::updateLibrary().

Here is the caller graph for this function:

◆ write()

Foam::Ostream & write ( Ostream os,
const bool  prefixed = false 
) const
inline

Write digest (40-byte) representation, optionally with '_' prefix.

Definition at line 127 of file SHA1I.H.

References os().

Referenced by Foam::operator<<().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator SHA1Digest()

operator SHA1Digest ( ) const
inline

Cast conversion to a SHA1Digest,.

calculates the digest from the current data

◆ operator==() [1/4]

bool operator== ( const SHA1 rhs) const
inline

Equality operator, compares digests.

Definition at line 141 of file SHA1I.H.

References SHA1::digest().

Here is the call graph for this function:

◆ operator==() [2/4]

bool operator== ( const SHA1Digest dig) const
inline

Compare digest.

Definition at line 147 of file SHA1I.H.

◆ operator==() [3/4]

bool operator== ( const std::string &  hexdigits) const
inline

Compare digest to (40-byte) text representation (eg, from sha1sum)

An empty string is equivalent to "0000000000000000000000000000000000000000"

Definition at line 153 of file SHA1I.H.

◆ operator==() [4/4]

bool operator== ( const char *  hexdigits) const
inline

Compare digest to (40-byte) text representation (eg, from sha1sum)

A null or empty string is equivalent to "0000000000000000000000000000000000000000"

Definition at line 159 of file SHA1I.H.

◆ operator!=() [1/4]

bool operator!= ( const SHA1 rhs) const
inline

Inequality operator, compares digests.

Definition at line 165 of file SHA1I.H.

References Foam::operator==().

Here is the call graph for this function:

◆ operator!=() [2/4]

bool operator!= ( const SHA1Digest rhs) const
inline

Inequality operator, compare digest.

Definition at line 171 of file SHA1I.H.

References Foam::operator==().

Here is the call graph for this function:

◆ operator!=() [3/4]

bool operator!= ( const std::string &  hexdigits) const
inline

Inequality operator, compares digests.

Definition at line 177 of file SHA1I.H.

References Foam::operator==().

Here is the call graph for this function:

◆ operator!=() [4/4]

bool operator!= ( const char *  hexdigits) const
inline

Inequality operator, compare digest.

Definition at line 183 of file SHA1I.H.

References Foam::operator==().

Here is the call graph for this function:

The documentation for this class was generated from the following files: