Check File

Verb: hashTest

Available from: <Standard>

Checks whether a file hash matches a specific hash code, using a text variable of type "String" entered in the Hash Text or a hashed text file entered in the Hash File, returning a boolean to indicate hash matching.

A hash function is an algorithm that maps variable length data to fixed length data.

Syntax

hashTest [--isfromfile(Boolean)] --hashfile(String) --hashstring(String) --filename(String) [--type(HashType)] (Boolean)=value

Inputs

Script Designer Required AcceptedTypes Description
--isfromfile Use File Optional Boolean Enables the use of Hash File to check hash match
--hashfile Hash File Only whenUse File is True Text Full path to the file containing the hash code used to check hash match.
--hashstring Hash Text Only whenUse File is False Text Hash code used to check hash match.
--filename File Name Required Text Full path of the file that should have its hash checked.
--type Algorithm Optional HashType Type of hash function to be used in the comparison, The options below are available:
  • CRC32
  • MD5
  • RIPMD160
  • SHA1
  • SHA256
  • SHA384
  • SHA512
  • Outputs

    Script Designer AcceptedTypes Description
    value Result Boolean Boolean that reports the file's match with the hash code: "True" if the hash code of the file set in the File Name parameter matches the hash code inserted, and "False" if the hash code from File Name does not match the hash code inserted.

    Example

    Example 1: Checks whether the hash code of the file from the "filePath" variable matches the hash code "a58ec78ef0ecc22e6a8079b12727ebd6".

    defVar --name matchesTheHash --type Boolean
    defVar --name filePath --type String
    //Import of file to be verified.
    import --name file --type "File" --content V0RHIEF1dG9tYXRpb24= --extension ".txt"
    export --asset "${asset.file}" filePath=value
    //Check file integrity according to hash "a58ec78ef0ecc22e6a8079b12727ebd6" of type MD5
    hashTest --hashstring a58ec78ef0ecc22e6a8079b12727ebd6 --filename "${filePath}" --type "MD5" matchesTheHash=value
    logMessage --message "File Matches Hash Code: ${matchesTheHash}" --type "Info"
    //This example produces the following result:
    //File Matches Hash Code: True
    

    Example 2: Checks whether the hash code of the file from the "filePath" variable matches the hash code in the file from the "hashCodeFile" variable.

    defVar --name matchesTheHash --type Boolean
    defVar --name filePath --type String
    defVar --name hashCodeFile --type String
    //Importing files.
    import --name file --type "File" --content V0RHIEF1dG9tYXRpb24= --extension ".txt"
    import --name hashCodeFile --type "File" --content YTU4ZWM3OGVmMGVjYzIyZTZhODA3OWIxMjcyN2ViZDY= --extension ".txt"
    export --asset "${asset.file}" filePath=value
    export --asset "${asset.hashCodeFile}" hashCodeFile=value
    //Checks file integrity for hash inserted into another file using MD5 type.
    hashTest --isfromfile  --hashfile "${hashCodeFile}" --filename "${filePath}" --type "MD5" matchesTheHash=value
    logMessage --message "File Matches Hash Code: ${matchesTheHash}" --type "Info"
    // This example produces the following result:
    // File Matches Hash Code: True
    

    See Also

  • Add Escape Characters to Regular Expression
  • Add Escape Characters to Text
  • Calculate Hash
  • Change Text Case
  • Compare Two Files
  • Concatenate Texts
  • Convert HTML to Text
  • Count Occurrences in Text
  • Count Text Characters
  • Create Random Text
  • Create Table By Regular Expression
  • Empty or Null Text Variable
  • Find by Regular Expression
  • Find Occurrences in Text
  • Format Text
  • Get Subtext
  • Get Text from Regular Expression
  • HTML to Markdown
  • Insert New Line to Text
  • Join Text
  • Pad Text
  • Parse URI
  • Remove Diacritics
  • Remove Escape Characters
  • Replace Part of Text
  • Replace Text
  • Split Text
  • Trim Text Blanks