File System - Get File Checksum

Declaration

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

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 filename of the file to retrieve checksum information from.

Checksum algorithm

Text

 (options)

No

CRC

  1. HASHTYPE="CRC"

  2. HASHTYPE="MD5"

  3. HASHTYPE="SHA1"

  4. HASHTYPE="SHA256"

  5. HASHTYPE="SHA384"

  6. 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 Create variable 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.

Description: Calculate the checksum of file "C:\Temp\extract.pdf" using the "MD5" algorithm and store the result in variable "theChecksum" then display the value in a message box.

 

<AMVARIABLE NAME="theChecksum" />

<AMFILESYSTEM ACTIVITY="get_checksum" FILE="C:\Temp\extract.pdf" RESULTVARIABLE="theChecksum" HASHTYPE="md5" />

<AMSHOWDIALOG WINDOWTITLE="Checksum">MD5 Checksum Value = %theChecksum%</AMSHOWDIALOG>