FB_CalcHashValue

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.

FB_CalcHashValue 1: Methods start()

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

METHOD start : BOOL
VAR_INPUT
    hashMode : E_HashMode;
END_VAR

Name

Description

hashMode

A hash mode, such as SHA 512, is specified here. See E_HashMode.

FB_CalcHashValue 2: Methods update()

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

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

Name

Description

pData

The address of the input data is specified here.

nData

The size of the input data in bytes is specified here.

FB_CalcHashValue 3: Methods finish()

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

VAR_INPUT
    pHash : PVOID;
    nHash : UDINT;
END_VAR

Name

Description

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.

Requirements

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) >= 3.3.51.0