Open Source Cross-Platform Game Programming

CryptoCommon

Contains the common base class for cryptographic hash libraries

class AbstractHash[link]

The abstract base class for the cryptographic hashes in other libraries, such as SHA1. Contains the common methods for adding data to the hash and generating a digest.

function addByte(value)[link]

Adds a single byte value to the hash.

Arguments

NameTypeDescription
value integer

A byte value from 0 to 255 (signed bytes from -128 to -1 are also allowed).

Return Value

TypeDescription
CryptoCommon.AbstractHash

A reference to itself to allow chaining syntax.

function addInteger(value)[link]

Adds an integer to the hash. The integer is converted into 32-bit signed Big Endian bytes.

Arguments

NameTypeDescription
value integer

An integer value

Return Value

TypeDescription
CryptoCommon.AbstractHash

A reference to itself to allow chaining syntax.

function addText(value, encoding)[link]

Adds the string as text to the current hash.

Arguments

NameTypeOptionalDescription
value string

A text value to add to the hash.

encoding TextEncoding.TextFormat Optional

Because cryptographic hashes work with bytes, a string must have an encoding to convert to binary data. If not specified, UTF8 is used.

Return Value

TypeDescription
CryptoCommon.AbstractHash

A reference to itself to allow chaining syntax.

function digestByteList()[link]

Digests the current data into a list of bytes.

Return Value

TypeDescription
int list

A list of bytes from 0 to 255

function digestHex()[link]

Digests the current data into a (lowercase) hexadecimal string.

Return Value

TypeDescription
string

A hexadecimal hash value