File System - Get file checksum

Declaration

<AMFILESYSTEM ACTIVITY="get_checksum" FILE="text" RESULTVARIABLE="text" HASHTYPE="text (options)" />

Related Topics    

Description

Generates a hash (checksum) value for a file and places it into an existing variable. While CRC (Cyclical Redundancy Checking) is the default algorithm, this activity also supports MD5 (Message Digest 5) and several SHA (Secure Hash Algorithm) variants. Available algorithms are placed 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

Property Type Required Default Markup Description
File Text Yes (Empty) FILE="c:\folder\file.txt" The path and file name of the file to retrieve checksum information from. This can be a fully qualified path and file name (preferred) or a single file (requires use of the File System - Change folder activity). Wildcard characters (for example, * or ?) may be used to specify all files matching a certain mask. Multiple files and/or file masks can be specified by separating each entry with a pipe character (|) (for example, c:\temp\*.txt|c:\backup\*.bak). See File Masks & Wildcards for more details.
Checksum algorithm Text (options) No CRC
  • HASHTYPE="CRC"
  • HASHTYPE="MD5"
  • HASHTYPE="SHA1"
  • HASHTYPE="SHA256"
  • HASHTYPE="SHA384"
  • HASHTYPE="SHA512"
The algorithm to use for calculation. Available algorithms are placed in order from quickest but least efficient to slowest but most efficient. 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" The name of an existing variable in which to populate with the checksum value. The variable must be created in a previous step using the Variable - Create activity.

Description

Error Causes

On Error

Example

NOTE:
  • The sample AML code below can be copied and pasted directly into the Steps Panel of the Task Builder.
  • Parameters containing user credentials, files, file paths, and/or other information specific to the task must be customized before the sample code can run successfully.

Description

This sample task calculates the checksum of a file and then stores the results in a variable.

Copy
<AMVARIABLE NAME="theChecksum" />
<AMFILESYSTEM ACTIVITY="get_checksum" FILE="C:\Temp\extract.pdf" RESULTVARIABLE="theChecksum" HASHTYPE="md5" />
<AMSHOWDIALOG WINDOWTITLE="Checksum">MD5 Checksum Value = %theChecksum%</AMSHOWDIALOG>