libxcks  0.1.0.1
libxcks::CRC64 Class Referencefinal

Computes the CRC-64 (ECMA 182 standard) from a byte stream. More...

#include <crc64.hpp>

Inheritance diagram for libxcks::CRC64:
Collaboration diagram for libxcks::CRC64:

Public Member Functions

 CRC64 ()
 Default constructor. More...
 
void reset () override
 Resets the CRC64 to initial value. More...
 
uint64_t getUint64Value () const
 Returns the CRC64 value. More...
 
std::string toString (const bool hexInUpperCase=false) const override
 Returns the CRC64 value in a string. More...
 
uint8_t * getValue (uint8_t *buffer) const override
 Returns the CRC64 value in the first 8 bytes of the given address. More...
 
size_t getSize () const override
 Returns the minimal size to allocate in memory to store the checksum with the getValue(buffer) method. More...
 
void update (const uint8_t *buf, size_t len) override
 Updates the CRC64 with specified array of bytes. More...
 
std::string getName () const override
 Returns the name of the checksum or the hash algorithm. More...
 
ArrayString getAltNames () const override
 Returns the alternative names of the CRC64 checksum algorithm. More...
 
ChecksumAlgoId getID () const override
 Returns an unique identifier for the checksum or the hash algorithm. More...
 
- Public Member Functions inherited from libxcks::Checksum
virtual ~Checksum ()
 Destructor. More...
 

Static Public Member Functions

static std::string getChecksumName ()
 Returns the name of the checksum algorithm. More...
 
static constexpr ChecksumAlgoId getIdentifier ()
 Returns an unique identifier for the checksum algorithm. More...
 
static ArrayString getAlternativeNames ()
 Returns the alternative names of the CRC64 checksum algorithm. More...
 
static ChecksumgetNewInstance ()
 Gets a new instance of this class. More...
 
- Static Public Member Functions inherited from libxcks::Checksum
static ArrayString getAlternativeNames ()
 Returns the alternative name(s) of the checksum or the hash algorithm. More...
 

Protected Attributes

uint64_t crc64
 The current CRC64 value. More...
 

Static Protected Attributes

static const uint64_t crc_table [256]
 Table used to compute the CRC64 value. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from libxcks::ChecksumEx
static uint32_t swapOnLE (const uint32_t value)
 Swaps bytes on little endian architectures. More...
 
static uint32_t swapOnBE (const uint32_t value)
 Swaps bytes on big endian architectures. More...
 
static uint64_t swapOnLE (const uint64_t value)
 Swaps bytes on little endian architectures. More...
 
static uint64_t swapOnBE (const uint64_t value)
 Swaps bytes on big endian architectures. More...
 

Detailed Description

Computes the CRC-64 (ECMA 182 standard) from a byte stream.

This class is written with the code found in LibCRC.

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

The CRC-64 checksum value can be gotten by the getUint64Value method which puts the CRC64 checksum value in an unsigned 64 bits integer.

The CRC64 checksum computing can be reseted by the reset method.

Definition at line 51 of file crc64.hpp.

Constructor & Destructor Documentation

◆ CRC64()

libxcks::CRC64::CRC64 ( )

Default constructor.

Definition at line 78 of file crc64.cpp.

Member Function Documentation

◆ getAlternativeNames()

ArrayString libxcks::CRC64::getAlternativeNames ( )
static

Returns the alternative names of the CRC64 checksum algorithm.

Returns
The alternative names of the CRC64 checksum algorithm.

Definition at line 155 of file crc64.cpp.

◆ getAltNames()

ArrayString libxcks::CRC64::getAltNames ( ) const
inlineoverridevirtual

Returns the alternative names of the CRC64 checksum algorithm.

Returns
The alternative names of the CRC64 checksum algorithm.

Reimplemented from libxcks::Checksum.

Definition at line 129 of file crc64.hpp.

◆ getChecksumName()

static std::string libxcks::CRC64::getChecksumName ( )
inlinestatic

Returns the name of the checksum algorithm.

Returns
The name of the checksum algorithm.

Definition at line 153 of file crc64.hpp.

◆ getID()

ChecksumAlgoId libxcks::CRC64::getID ( ) const
inlineoverridevirtual

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

Remarks
The unique ID should be the CRC64 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.

Implements libxcks::Checksum.

Definition at line 143 of file crc64.hpp.

◆ getIdentifier()

static constexpr ChecksumAlgoId libxcks::CRC64::getIdentifier ( )
inlinestaticconstexpr

Returns an unique identifier for the checksum algorithm.

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

Definition at line 168 of file crc64.hpp.

◆ getName()

std::string libxcks::CRC64::getName ( ) const
inlineoverridevirtual

Returns the name of the checksum or the hash algorithm.

Returns
The name of the checksum or the hash algorithm.

Implements libxcks::Checksum.

Definition at line 119 of file crc64.hpp.

◆ getNewInstance()

static Checksum* libxcks::CRC64::getNewInstance ( )
inlinestatic

Gets a new instance of this class.

The caller is responsible of the deletion of the instance with the delete operator.

Returns
A new instance of this class.

Definition at line 188 of file crc64.hpp.

◆ getSize()

size_t libxcks::CRC64::getSize ( ) const
inlineoverridevirtual

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.

Implements libxcks::Checksum.

Definition at line 104 of file crc64.hpp.

◆ getUint64Value()

uint64_t libxcks::CRC64::getUint64Value ( ) const

Returns the CRC64 value.

Returns
The current checksum value.

Definition at line 98 of file crc64.cpp.

◆ getValue()

uint8_t * libxcks::CRC64::getValue ( uint8_t *  buffer) const
overridevirtual

Returns the CRC64 value in the first 8 bytes of the given address.

Parameters
bufferThe buffer where the CRC64 value will be stored.
Returns
The address of the buffer.
Remarks
The memory for the 8 bytes must have been allocated before calling this method.

Implements libxcks::Checksum.

Definition at line 108 of file crc64.cpp.

◆ reset()

void libxcks::CRC64::reset ( )
overridevirtual

Resets the CRC64 to initial value.

Implements libxcks::ChecksumEx.

Definition at line 88 of file crc64.cpp.

◆ toString()

string libxcks::CRC64::toString ( const bool  hexInUpperCase = false) const
overridevirtual

Returns the CRC64 value in a string.

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

Reimplemented from libxcks::ChecksumEx.

Definition at line 123 of file crc64.cpp.

◆ update()

void libxcks::CRC64::update ( const uint8_t *  buf,
size_t  len 
)
overridevirtual

Updates the CRC64 with specified array of bytes.

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

Implements libxcks::Checksum.

Definition at line 142 of file crc64.cpp.

Member Data Documentation

◆ crc64

uint64_t libxcks::CRC64::crc64
protected

The current CRC64 value.

Definition at line 58 of file crc64.hpp.

◆ crc_table

const uint64_t libxcks::CRC64::crc_table
staticprotected

Table used to compute the CRC64 value.

Definition at line 55 of file crc64.hpp.


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