Calculate File Checksum

Declaration

<AMCALCHASH FILE="Text" HASHTYPE="Text" RESULTVARIABLE="Text" />

See Also

Description

Generates a hash (checksum) value for a file and places it into the specified AutoMate variable. While CRC is the default algorithm, this action also supports MD5 and several SHA variants (in order from quickest but least efficient to slowest but most efficient).

Practical Usage

Commonly used to validate the integrity of data by calculating a checksum using the selected algorithm. The result is placed in a variable, which can be stored for later validation of the file or compared with an earlier checksum to verify the file's integrity.

Parameters

General Properties

Property

Type

Required

Default

Markup

Description

File

Text

Yes

(Empty)

FILE="c:\folder\file.txt"

Specifies the path and file name of the file to check.

Algorithm

Text

 (Options)

No

CRC

HASHTYPE="MD5"

Indicates the algorithm to use during calculation. The available options are:

  • CRC (default): Cyclical Redundancy Checking. Fastest and least secure.

  • MD5: Message Digest 5. Slower and more secure than CRC.

  • SHA1: Secure Hash Algorithm-1. Slower and more secure than MD5.

  • SHA256: Secure Hash Algorithm-256. Slower and more secure than SHA1.

  • SHA384: Secure Hash Algorithm-384. Slower and more secure than SHA256.

  • SHA512: Secure Hash Algorithm-512. Slowest and most secure.

Populate Variable with the Checksum

Text

No

(Empty)

RESULTVARIABLE="VarName"

Specifies the name of an existing AutoMate variable in which to populate with the checksum result. The variable must be created in a previous step using the Create Variable action.

 

Description Properties

The Description tab allows you to customize the text description of any step as it appears in the Task Builder's Steps Pane.

More on setting custom step description

Error Causes Properties

The Error Causes tab properties allows you to instruct a task step to react only to specific errors or ignore certain errors that should cause it to fail.

More on Error Causes properties

On Error Properties

The On Error tab properties lets you determine what the task should do if a particular step encounters an error as defined in the Error Causes properties.

More about On Error properties

Additional Notes

Expressions, Variables and Functions

All text fields allow the use of expressions such as variables, functions or AutoMate extended functions, which can be entered by surrounding the expression in percentage signs (example: %FileDateTime(myVar)% or %myVar%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by clicking the Insert Expression (%) button or by pressing F2.

More on expressions

More on variables

More on function

More on extended functions
More on the expression builder

Example

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

 

Description: Calculate the checksum of file "C:\FolderName\FileName.doc" using the "MD5" algorithm and store the result in variable "VariableName".

 

<AMCALCHASH FILE="C:\FolderName\FileName.doc" HASHTYPE="MD5" RESULTVARIABLE="VariableName" />

 

 

↑ Top of Page