SHA1Digest Class Reference

The SHA1 message digest. More...

Collaboration diagram for SHA1Digest:

Public Member Functions

 SHA1Digest ()
 Default construct a zero digest. More...
 
 SHA1Digest (Istream &is)
 Read construct a digest from stringified content. More...
 
 SHA1Digest (const char *content, std::size_t len)
 Construct digest from raw or stringified content. The length is 20 for raw digest content and 40 (or 41) for stringified versions. More...
 
 SHA1Digest (const unsigned char *content, std::size_t len)
 Construct digest from raw or stringified content. The length is 20 for raw digest content and 40 (or 41) for stringified versions. More...
 
void clear ()
 Reset the digest to zero. More...
 
bool empty () const
 Return true if the digest is empty (ie, all zero). More...
 
std::string str (const bool prefixed=false) const
 Return (40-byte) text representation, optionally with '_' prefix. More...
 
Istreamread (Istream &is)
 Read (40-byte) text representation. More...
 
Ostreamwrite (Ostream &os, const bool prefixed=false) const
 Write (40-byte) text representation, optionally with '_' prefix. More...
 
const unsigned char * cdata () const noexcept
 Raw digest data (20 bytes) - const access. More...
 
const char * cdata_bytes () const noexcept
 Raw digest char data (20 bytes) - const access. For consistency with other objects, these are not unsigned. More...
 
char * data_bytes () noexcept
 Raw digest char data (20 bytes) - non-const access. For consistency with other objects, these are not unsigned. Use with caution - generally for broadcasting only. More...
 
bool operator== (const SHA1Digest &rhs) const
 Equality operator. More...
 
bool operator== (const std::string &hexdigits) const
 Compare to (40-byte) text representation (eg, from sha1sum) More...
 
bool operator== (const char *hexdigits) const
 Compare to (40-byte) text representation (eg, from sha1sum) More...
 
bool operator!= (const SHA1Digest &rhs) const
 Inequality operator. More...
 
bool operator!= (const std::string &hexdigits) const
 Inequality operator. More...
 
bool operator!= (const char *hexdigits) const
 Inequality operator. More...
 

Static Public Member Functions

static constexpr unsigned size_bytes () noexcept
 The number of bytes in digest (20) More...
 
static constexpr unsigned max_size () noexcept
 The dimensioned size of the digest is always 20 bytes. More...
 

Static Public Attributes

static const SHA1Digest null
 A null digest (ie, all zero) More...
 

Friends

class SHA1
 

Detailed Description

The SHA1 message digest.

See also
Foam::SHA1
Source files

Definition at line 56 of file SHA1Digest.H.

Constructor & Destructor Documentation

◆ SHA1Digest() [1/4]

Default construct a zero digest.

Definition at line 163 of file SHA1Digest.C.

References SHA1Digest::clear().

Here is the call graph for this function:

◆ SHA1Digest() [2/4]

SHA1Digest ( Istream is)
explicit

Read construct a digest from stringified content.

Definition at line 183 of file SHA1Digest.C.

References clear(), and Foam::read().

Here is the call graph for this function:

◆ SHA1Digest() [3/4]

SHA1Digest ( const char *  content,
std::size_t  len 
)

Construct digest from raw or stringified content. The length is 20 for raw digest content and 40 (or 41) for stringified versions.

Definition at line 169 of file SHA1Digest.C.

References Foam::FieldOps::assign(), and clear().

Here is the call graph for this function:

◆ SHA1Digest() [4/4]

SHA1Digest ( const unsigned char *  content,
std::size_t  len 
)

Construct digest from raw or stringified content. The length is 20 for raw digest content and 40 (or 41) for stringified versions.

Definition at line 176 of file SHA1Digest.C.

References Foam::FieldOps::assign(), and clear().

Here is the call graph for this function:

Member Function Documentation

◆ clear()

void clear ( )

Reset the digest to zero.

Definition at line 192 of file SHA1Digest.C.

Referenced by SHA1Digest::SHA1Digest().

Here is the caller graph for this function:

◆ empty()

bool empty ( ) const

Return true if the digest is empty (ie, all zero).

Definition at line 198 of file SHA1Digest.C.

◆ str()

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

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

Definition at line 227 of file SHA1Digest.C.

References hexChars.

◆ read()

Foam::Istream & read ( Istream is)

Read (40-byte) text representation.

Since leading and intermediate underscores are skipped, a '_' can be prefixed to the text representation to use an unquoted SHA1Digest without parsing ambiguities as a number.

Definition at line 212 of file SHA1Digest.C.

References IOstream::check(), FUNCTION_NAME, and Foam::readHexDigit().

Referenced by Foam::operator>>().

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

◆ write()

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

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

Definition at line 252 of file SHA1Digest.C.

References IOstream::check(), FUNCTION_NAME, hexChars, os(), and OBJstream::write().

Referenced by Foam::operator<<(), and dynamicCode::writeDigest().

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

◆ cdata()

const unsigned char* cdata ( ) const
inlinenoexcept

Raw digest data (20 bytes) - const access.

Definition at line 151 of file SHA1Digest.H.

◆ cdata_bytes()

const char* cdata_bytes ( ) const
inlinenoexcept

Raw digest char data (20 bytes) - const access. For consistency with other objects, these are not unsigned.

Definition at line 157 of file SHA1Digest.H.

Referenced by fileOperation::getGlobalHostIORanks(), and Foam::getHostGroupIds().

Here is the caller graph for this function:

◆ data_bytes()

char* data_bytes ( )
inlinenoexcept

Raw digest char data (20 bytes) - non-const access. For consistency with other objects, these are not unsigned. Use with caution - generally for broadcasting only.

Definition at line 167 of file SHA1Digest.H.

◆ size_bytes()

static constexpr unsigned size_bytes ( )
inlinestaticnoexcept

The number of bytes in digest (20)

Definition at line 175 of file SHA1Digest.H.

◆ max_size()

static constexpr unsigned max_size ( )
inlinestaticnoexcept

The dimensioned size of the digest is always 20 bytes.

Definition at line 180 of file SHA1Digest.H.

Referenced by fileOperation::getGlobalHostIORanks(), and Foam::getHostGroupIds().

Here is the caller graph for this function:

◆ operator==() [1/3]

bool operator== ( const SHA1Digest rhs) const

Equality operator.

Definition at line 272 of file SHA1Digest.C.

◆ operator==() [2/3]

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

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

An empty string is equivalent to "0000000000000000000000000000000000000000" The hexdigits may optionally start with a '_' prefix

Definition at line 278 of file SHA1Digest.C.

◆ operator==() [3/3]

bool operator== ( const char *  hexdigits) const

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

A null or empty string is equivalent to "0000000000000000000000000000000000000000" The hexdigits may optionally start with a '_' prefix

Definition at line 287 of file SHA1Digest.C.

◆ operator!=() [1/3]

bool operator!= ( const SHA1Digest rhs) const

Inequality operator.

Definition at line 296 of file SHA1Digest.C.

References Foam::operator==().

Here is the call graph for this function:

◆ operator!=() [2/3]

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

Inequality operator.

Definition at line 302 of file SHA1Digest.C.

References Foam::operator==().

Here is the call graph for this function:

◆ operator!=() [3/3]

bool operator!= ( const char *  hexdigits) const

Inequality operator.

Definition at line 308 of file SHA1Digest.C.

References Foam::operator==().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ SHA1

friend class SHA1
friend

Definition at line 69 of file SHA1Digest.H.

Member Data Documentation

◆ null

const Foam::SHA1Digest null
static

A null digest (ie, all zero)

Definition at line 84 of file SHA1Digest.H.


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