sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
CRC32 Class Reference

compute CRC32 hash, based on Intel's Slicing-by-8 algorithm More...

#include <crc32.h>

Public Types

enum  { HashBytes = 4 }
 hash is 4 bytes long More...

Public Member Functions

 CRC32 ()
 same as reset()
std::string operator() (const void *data, size_t numBytes)
 compute CRC32 of a memory block
std::string operator() (const std::string &text)
 compute CRC32 of a string, excluding final zero
void add (const void *data, size_t numBytes)
 add arbitrary number of bytes
std::string getHash ()
 return latest hash as 8 hex characters
void getHash (unsigned char buffer[HashBytes])
 return latest hash as bytes
void reset ()
 restart

Detailed Description

compute CRC32 hash, based on Intel's Slicing-by-8 algorithm

Usage: CRC32 crc32; std::string myHash = crc32("Hello World"); // std::string std::string myHash2 = crc32("How are you", 11); // arbitrary data, 11 bytes

or in a streaming fashion:

CRC32 crc32;
while (more data available)
  crc32.add(pointer to fresh data, number of new bytes);
std::string myHash3 = crc32.getHash();

Note:
You can find code for the faster Slicing-by-16 algorithm on my website, too:
http://create.stephan-brumme.com/crc32/
Its unrolled version is about twice as fast but its look-up table doubled in size as well.

Definition at line 45 of file crc32.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

hash is 4 bytes long

Definition at line 49 of file crc32.h.

Constructor & Destructor Documentation

◆ CRC32()

CRC32::CRC32 ( )

same as reset()

Definition at line 18 of file crc32.cpp.

Member Function Documentation

◆ add()

void CRC32::add ( const void * data,
size_t numBytes )

add arbitrary number of bytes

Definition at line 341 of file crc32.cpp.

◆ getHash()

std::string CRC32::getHash ( )

return latest hash as 8 hex characters

Definition at line 385 of file crc32.cpp.

◆ operator()() [1/2]

std::string CRC32::operator() ( const std::string & text)

compute CRC32 of a string, excluding final zero

Definition at line 428 of file crc32.cpp.

◆ operator()() [2/2]

std::string CRC32::operator() ( const void * data,
size_t numBytes )

compute CRC32 of a memory block

Definition at line 419 of file crc32.cpp.

◆ reset()

void CRC32::reset ( )

restart

Definition at line 25 of file crc32.cpp.


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