JASSv2
Static Public Member Functions | List of all members
JASS::checksum Class Reference

Holder class for checksums, Cyclic Redundency Checks, and so on. More...

#include <checksum.h>

Static Public Member Functions

template<typename TYPE >
static uint16_t fletcher_16 (TYPE &start, TYPE &end)
 Compute the Fletcher 16-bit checksum of 8-bit data. Unlike a "regular" 8-bit checsum, this manages position as well as content. More...
 
static uint16_t fletcher_16 (const void *data, size_t length)
 Compute the Fletcher 16-bit checksum of a string (see the template verison details).. More...
 
static uint16_t fletcher_16 (const std::string &string)
 Compute the Fletcher 16-bit checksum of a string (see the template verison details).. More...
 
static uint16_t fletcher_16 (std::istream &stream)
 Compute the Fletcher 16-bit checksum of an istream (see the template verison for details).. More...
 
static uint16_t fletcher_16_file (const std::string &filename)
 Compute the Fletcher 16-bit checksum of a disk file. More...
 
static void unittest (void)
 Unit test this class. Checksums can be verified against:http://www.nitrxgen.net/hashgen/.
 

Detailed Description

Holder class for checksums, Cyclic Redundency Checks, and so on.

Member Function Documentation

◆ fletcher_16() [1/4]

template<typename TYPE >
uint16_t JASS::checksum::fletcher_16 ( TYPE &  start,
TYPE &  end 
)
static

Compute the Fletcher 16-bit checksum of 8-bit data. Unlike a "regular" 8-bit checsum, this manages position as well as content.

The Fletcher checksum was designed to identify when two bytes in an 8-bit data-stream are swapped over. which a "regular" checksum cannot detect. For details see: Fletcher, J. G. (1982). An Arithmetic Checksum for Serial Transmissions. IEEE Transactions on Communications. COM-30 (1): 247-252. doi:10.1109/tcom.1982.1095369 The Wikipedia article is: https://en.wikipedia.org/wiki/Fletcher's_checksum Dr Dobbs has an article that examines how good the algorithm is: http://www.drdobbs.com/database/fletchers-checksum/184408761

Parameters
start[in] A pointer to a sequence of bytes to checksum.
end[in] A pointer to the end of the buffer.
Returns
The Fletcher 16-bit checksum of the 8-bit sequence.

◆ fletcher_16() [2/4]

uint16_t JASS::checksum::fletcher_16 ( const void *  data,
size_t  length 
)
static

Compute the Fletcher 16-bit checksum of a string (see the template verison details)..

Parameters
data[in] A pointer to a sequence of bytes of length length to checksum.
length[in] The number of bytes to checksum.
Returns
The Fletcher 16-bit checksum of the 8-bit sequence.

◆ fletcher_16() [3/4]

static uint16_t JASS::checksum::fletcher_16 ( const std::string &  string)
inlinestatic

Compute the Fletcher 16-bit checksum of a string (see the template verison details)..

Parameters
string[in] A C++ string to checksum.
Returns
The Fletcher 16-bit checksum of the string.

◆ fletcher_16() [4/4]

uint16_t JASS::checksum::fletcher_16 ( std::istream &  stream)
static

Compute the Fletcher 16-bit checksum of an istream (see the template verison for details)..

Parameters
stream[in] The stream to checksum
Returns
The Fletcher 16-bit checksum of the stream.

◆ fletcher_16_file()

uint16_t JASS::checksum::fletcher_16_file ( const std::string &  filename)
static

Compute the Fletcher 16-bit checksum of a disk file.

Parameters
filename[in] The path to the file to checksum.
Returns
The Fletcher 16-bit checksum of the file.

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