Calculate Hash

Calculates the hash of a text or file.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

Calculates the hash code of a text or file by using a hash function.

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.

hashCalculate [--isfromfile(Boolean)] --filename(String) --text(String) [--type(HashType)] (String)=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
Use File isfromfile Optional Boolean Enable it to use the File parameter, therefore allowing entering a file as input.
File filename Required when the Use File parameter is enabled Text Full path of the text file used to calculate hash code.
Text text Required when the Use File parameter is not enabled Text Text used to calculate hash code.
Hash Function type Optional HashType Hash function used to calculate the hash. For more information see the type parameter options.

type parameter options

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
Hash code value Text Returns the hash code calculated at File or Text.

Example

The command is used to calculate and returns the hash code of the text "IBM".

defVar --name textHash --type String
// Calculate the hash of the text "IBM".
hashCalculate --text "IBM" --type "MD5" textHash=value
logMessage --message "${textHash}\r\n" --type "Info"