Classes | Public Member Functions | Friends | List of all members
openmsx::Sha1Sum Class Reference

This class represents the result of a sha1 calculation (a 160-bit value). More...

#include <sha1.hh>


struct  UninitializedTag

Public Member Functions

 Sha1Sum (UninitializedTag)
 Sha1Sum ()
 Sha1Sum (std::string_view hex)
 Construct from string, throws when string is malformed.
void parse40 (std::span< const char, 40 > str)
 Parse from a 40-character long buffer.
std::string toString () const
bool empty () const
void clear ()
constexpr auto operator<=> (const Sha1Sum &) const =default


class SHA1
std::ostream & operator<< (std::ostream &os, const Sha1Sum &sum)

Detailed Description

This class represents the result of a sha1 calculation (a 160-bit value).

Objects of this class can be constructed from/converted to 40-digit hex string. We treat the value '000...00' (all zeros) special. This value can be used to indicate a null-sha1sum value (e.g. sha1 not yet calculated, or not meaningful). In theory it's possible this special value is the result of an actual sha1 calculation, but this has an extremely low probability.

Definition at line 23 of file sha1.hh.

Constructor & Destructor Documentation

◆ Sha1Sum() [1/3]

openmsx::Sha1Sum::Sha1Sum ( UninitializedTag  )

Definition at line 27 of file sha1.hh.

◆ Sha1Sum() [2/3]

openmsx::Sha1Sum::Sha1Sum ( )

Definition at line 100 of file utils/

References clear().

◆ Sha1Sum() [3/3]

openmsx::Sha1Sum::Sha1Sum ( std::string_view  hex)

Construct from string, throws when string is malformed.

Definition at line 105 of file utils/

References parse40().

Member Function Documentation

◆ clear()

void openmsx::Sha1Sum::clear ( )

Definition at line 250 of file utils/

References ranges::fill().

Referenced by openmsx::SectorAccessibleDisk::flushCaches(), and Sha1Sum().

◆ empty()

bool openmsx::Sha1Sum::empty ( ) const

◆ operator<=>()

constexpr auto openmsx::Sha1Sum::operator<=> ( const Sha1Sum ) const

◆ parse40()

void openmsx::Sha1Sum::parse40 ( std::span< const char, 40 >  str)

Parse from a 40-character long buffer.

'str' points to a buffer of at least 40 characters
MSXExceptionif chars are not 0-9, a-f, A-F

Definition at line 143 of file utils/

References repeat(), and t.

Referenced by Sha1Sum(), and TEST_CASE().

◆ toString()

std::string openmsx::Sha1Sum::toString ( ) const

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const Sha1Sum sum 

Definition at line 47 of file sha1.hh.

◆ SHA1

friend class SHA1

Definition at line 54 of file sha1.hh.

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