Compare Two Files

Compares the contents of two files.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

Compares the contents of two files by checking if their hash signature matches, returning a boolean variable that asserts if the files are equal or not.

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

hashCompare --filename1(String) --FileName2(String) [--type(HashType)] (Boolean)=value

Limitations

The following algorithms are not available in environments with FIPS encryption enabled:

  • CRC32
  • MD5
  • RIPEMD-160

Input parameters

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
First File filename1 Required Text Full path to the first file.
Second File FileName2 Required Text Full path to the second file.
Algorithm type Optional HashType Type of hash function to be used for comparison. For more information, see the type parameter options

type parameter options

The following algorithms are available

Algorithm Description
CRC32 A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to raw data. It was developed by Hewlett-Packard in 1961 and is still widely used today. CRC32 is a 32-bit checksum algorithm that uses a polynomial division remainder to detect errors in data.
MD5 MD5 Message-Digest Algorithm is a cryptographic hash function that takes an input and produces a 128-bit hash value. It is a widely used hash function and is used to verify the integrity of data. MD5 is a one-way hash function, which means it is easy to compute the hash value for any given input, but it is computationally expensive to reverse the hash value back to the original input.
RIPEMD-160 RIPEMD-160 is a cryptographic hash function that produces a 160-bit hash value. It is designed to be faster than SHA-1 and has been proven to have better security properties. RIPEMD-160 is a variant of the RIPEMD family of hash functions, which includes RIPEMD-128, RIPEMD-160, and RIPEMD-256.
SHA-1 SHA-1 is a cryptographic hash function that produces a 160-bit hash value. It is a secure hash algorithm and is widely used in cryptography and computer security. SHA-1 is a variant of the Secure Hash Standard (SHS), which was published by NSA in 1993.
SHA-256 SHA-256 is a cryptographic hash function that produces a 256-bit hash value. It is a successor to SHA-1 and is considered to be more secure than SHA-1. It is a member of the SHA-2 family of hash functions.
SHA-384 SHA-384 is a cryptographic hash function that produces 384-bit hash values. It is a member of the SHA-2 family of hash functions.
SHA-512 SHA-512 is a cryptographic hash function that produces 512-bit hash values. It is a member of the SHA-2 family of hash functions.

Output parameters

Designer mode label Script mode name Accepted variable types Description
Equality value Boolean Returns "True" if the files are the same or "False" if the files are different.

Example

The command compares the two reported files and returns the result of the comparison: "True".

defVar --name comparisonResult --type Boolean
// Download the following files to run the command.
hashCompare --filename1 "fileText.txt" --type "MD5" comparisonResult=value
logMessage --message "Comparison Result: ${comparisonResult}" --type "Info"