This function block calculates a hash value.

For this purpose the methods start(), update() and finish() are used.

The methods decouple the appending of input data from the actual calculation of the hash value and also allow input data to be appended piece by piece in multiple steps. If it is not necessary to add input data multiple times, it is recommended to use the function F_GenerateHashValue() instead of the function block.

Start() method

This method initializes the hash calculation with the specified hash mode.

    hashMode : E_HashMode;

hashMode: a hash mode, such as SHA 512, is specified here. See E_HashMode.

Method update()

This method can be called once or multiple times. Input data for the hash calculation is added with each call.

METHOD update : BOOL
    pData : PVOID;
    nData : UDINT;

pData: the address of the input data is specified here.

nData: the size of the input data in bytes is specified here.

Method finish()

This method performs the hash calculation and outputs the calculated hash value.

    pHash : PVOID;
    nHash : UDINT;

pHash: here the address of the buffer is specified where the hash value is to be stored.

nHash: the size of the buffer for the hash value is specified here. The size depends on the hash mode, see also E_HashMode.


Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.4024.29

PC or CX (x86, x64, ARM)

Tc2_Utilities (System) >=