libxcks  0.1.0.1
libxcks::Checksum Class Referenceabstract

Computes a checksum from a byte stream. More...

#include <checksum.hpp>

Inheritance diagram for libxcks::Checksum:

Public Member Functions

virtual ~Checksum ()
 Destructor. More...
 
virtual void reset ()=0
 Resets the checksum to initial value. More...
 
virtual std::string toString (const bool hexInUpperCase=false) const =0
 Returns the checksum value in a string. More...
 
virtual uint8_t * getValue (uint8_t *buffer) const =0
 Returns the checksum value in the first bytes of the given address. More...
 
virtual size_t getSize () const =0
 Returns the minimal size to allocate in memory to store the checksum with the getValue(buffer) method. More...
 
virtual void update (const uint8_t *buf, size_t len)=0
 Updates the checksum with specified array of bytes. More...
 
virtual std::string getName () const =0
 Returns the name of the checksum or the hash algorithm. More...
 
virtual ArrayString getAltNames () const
 Returns the alternative name(s) of the checksum or the hash algorithm. More...
 
virtual ChecksumAlgoId getID () const =0
 Returns an unique identifier for the checksum or the hash algorithm. More...
 

Static Public Member Functions

static ArrayString getAlternativeNames ()
 Returns the alternative name(s) of the checksum or the hash algorithm. More...
 

Detailed Description

Computes a checksum from a byte stream.

Using this class in very simple:
Use the update method to provide to the class the bytes for computing the checksum.

The checksum value can be gotten by the toString method which puts the checksum value in a string or getValue to get an array of bytes.

The checksum computing can be reseted by the reset method.

Definition at line 53 of file checksum.hpp.

Constructor & Destructor Documentation

◆ ~Checksum()

virtual libxcks::Checksum::~Checksum ( )
inlinevirtual

Destructor.

Definition at line 59 of file checksum.hpp.

Member Function Documentation

◆ getAlternativeNames()

static ArrayString libxcks::Checksum::getAlternativeNames ( )
inlinestatic

Returns the alternative name(s) of the checksum or the hash algorithm.

Returns
The alternative name(s) of the checksum or the hash algorithm.

Definition at line 137 of file checksum.hpp.

◆ getAltNames()

virtual ArrayString libxcks::Checksum::getAltNames ( ) const
inlinevirtual

Returns the alternative name(s) of the checksum or the hash algorithm.

Returns
The alternative name(s) of the checksum or the hash algorithm.

Reimplemented in libxcks::SHA3_512, libxcks::SHA3_384, libxcks::SHA3_256, libxcks::SHA3_224, libxcks::SHA512, libxcks::SHA384, libxcks::SHA256, libxcks::SHA224, libxcks::SHA1, libxcks::CRC64, libxcks::CRC32, and libxcks::RIPEMD160.

Definition at line 116 of file checksum.hpp.

◆ getID()

virtual ChecksumAlgoId libxcks::Checksum::getID ( ) const
pure virtual

Returns an unique identifier for the checksum or the hash algorithm.

Remarks
The unique ID should be the CRC32 checksum of the algorithm's name returned by getName() but it's only a convention.
Returns
An unique identifier for the checksum or the hash algorithm.

Implemented in libxcks::SHA3_512, libxcks::SHA3_384, libxcks::SHA3_256, libxcks::SHA3_224, libxcks::Whirlpool, libxcks::Tiger, libxcks::SM3, libxcks::SHA512, libxcks::SHA384, libxcks::SHA256, libxcks::SHA224, libxcks::SHA1, libxcks::RIPEMD160, libxcks::MD5, libxcks::MD4, libxcks::MD2, libxcks::CRC64, libxcks::CRC32, and libxcks::BLAKE3.

◆ getName()

virtual std::string libxcks::Checksum::getName ( ) const
pure virtual

◆ getSize()

virtual size_t libxcks::Checksum::getSize ( ) const
pure virtual

Returns the minimal size to allocate in memory to store the checksum with the getValue(buffer) method.

Returns
The minimal size to allocate in memory to store the checksum with the getValue(buffer) method.

Implemented in libxcks::SHA3_512, libxcks::SHA3_384, libxcks::SHA3_256, libxcks::SHA3_224, libxcks::Whirlpool, libxcks::Tiger, libxcks::SM3, libxcks::SHA512, libxcks::SHA384, libxcks::SHA256, libxcks::SHA224, libxcks::SHA1, libxcks::RIPEMD160, libxcks::MD5, libxcks::MD4, libxcks::MD2, libxcks::CRC64, libxcks::CRC32, and libxcks::BLAKE3.

◆ getValue()

virtual uint8_t* libxcks::Checksum::getValue ( uint8_t *  buffer) const
pure virtual

Returns the checksum value in the first bytes of the given address.

Parameters
bufferThe buffer where the checksum value will be stored.
Returns
The address of the buffer.
Remarks
The memory must have been allocated before calling this method. The minimal size to allocate is given by the getSize() method.

Implemented in libxcks::SHA3_512, libxcks::SHA3_384, libxcks::Whirlpool, libxcks::Tiger, libxcks::SM3, libxcks::SHA512, libxcks::SHA384, libxcks::SHA256, libxcks::SHA224, libxcks::SHA1, libxcks::RIPEMD160, libxcks::MD5, libxcks::MD4, libxcks::MD2, libxcks::SHA3_256, libxcks::SHA3_224, libxcks::CRC64, libxcks::CRC32, and libxcks::BLAKE3.

◆ reset()

◆ toString()

virtual std::string libxcks::Checksum::toString ( const bool  hexInUpperCase = false) const
pure virtual

Returns the checksum value in a string.

Parameters
hexInUpperCaseIf true the hexadecimal letters will be in uppercase.
Returns
The current checksum value.

Implemented in libxcks::CRC64, libxcks::CRC32, and libxcks::ChecksumEx.

◆ update()

virtual void libxcks::Checksum::update ( const uint8_t *  buf,
size_t  len 
)
pure virtual

Updates the checksum with specified array of bytes.

Parameters
bufThe byte array to update the checksum with.
lenThe number of bytes to use for the update.

Implemented in libxcks::AbstractSHA512Impl, libxcks::AbstractSHA256Impl, libxcks::AbstractKeccakImpl, libxcks::Whirlpool, libxcks::Tiger, libxcks::SM3, libxcks::SHA1, libxcks::RIPEMD160, libxcks::MD5, libxcks::MD4, libxcks::MD2, libxcks::CRC64, libxcks::CRC32, and libxcks::BLAKE3.


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