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. More...
void parse40 (const char *str)
 Parse from a 40-character long buffer. More...
std::string toString () const
bool empty () const
void clear ()
bool operator== (const Sha1Sum &other) const
constexpr auto operator<=> (const Sha1Sum &other) const


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 21 of file sha1.hh.

Constructor & Destructor Documentation

◆ Sha1Sum() [1/3]

openmsx::Sha1Sum::Sha1Sum ( UninitializedTag  )

Definition at line 25 of file sha1.hh.

◆ Sha1Sum() [2/3]

openmsx::Sha1Sum::Sha1Sum ( )

Definition at line 95 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 100 of file utils/

References parse40().

Member Function Documentation

◆ clear()

void openmsx::Sha1Sum::clear ( )

Definition at line 245 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 other) const

Definition at line 52 of file sha1.hh.

References xrange().

◆ operator==()

bool openmsx::Sha1Sum::operator== ( const Sha1Sum other) const

Definition at line 46 of file sha1.hh.

References xrange().

◆ parse40()

void openmsx::Sha1Sum::parse40 ( const char *  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 138 of file utils/

References repeat(), and t.

Referenced by Sha1Sum().

◆ toString()

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

Friends And Related Function Documentation

◆ operator<<

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

Definition at line 59 of file sha1.hh.

◆ SHA1

friend class SHA1

Definition at line 66 of file sha1.hh.

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