Skip to main content

TrFile_GetFileHash (function reference)

By June 1, 2024June 4th, 2024Online Help, Troi File Plug-in
Troi File Plug-in > Functions reference > TrFile_GetFileHash
Troi File Plug-in for FileMaker Pro


Returns the MD5 or SHA1 hash value (checksum) of a file.

SyntaxFunction badge

TrFile_GetFileHash ( switches ; sourcefile )


switches determines the behavior of the function
sourcefile the path to the file of which you want the hash value, or container data


Switches must be one of this:

-MD5 use the MD5 algorithm to calculate the hash.
-SHA1 use the SHA-1 algorithm to calculate the hash.

You can also add this switch below:

-Colons add colons between the result, for easy human reading

Returned Result

Data type returned



the hash value, which is a text of 32 or 40 characters.

If the file does not exist or if an error occurs an error code will be returned, starting with $$. Returned error codes can be:

$$-43 fnfErr File or folder not found
$$-50 paramErr Parameter error

Originated in

Troi File Plug-in 6.0


FileMaker Pro 17 to FileMaker Pro 21 (2024)


The function result is also called a message-digest. It provides an easy way to check if a file has not changed (by comparing it to a stored hash). Also you can use this hash to check if two files are identical.

Note: On macOS only the data fork of a file is considered. The resource fork of a file is ignored.

SHA-1 is considered more secure as it is a longer hash (160-bit).

Starting with v12.1: you can also use a container (or a variable with container data) as the source parameter, for example a JPEG in a container field


TrFile_GetFileHash ( "-SHA1" ;  "C:\Test.txt" ) ]

This will return the SHA1 hash value which looks like this: “65c25a0c4ad167d9394298beaf93d0e630d2767a”

Example 2

Set Variable [ $hash ; TrFile_GetFileHash ( "-MD5 -Colons" ; "filemac:/Mac HD/Users/Smith/report.txt" ) ]

This will set the variable $hash to the MD5 hash value of the file. The result will be formatted, for easier reading, with colons between each byte and looks similar to this:


Used in example file


Related functionsFunction badge


Related topics

Troi File Plug-in online help (overview)

Online Help Page for Troi File Plug-in for 17 to 2024 –> TrFile_GetFileHash (filep4301) 2024-0604 19:09:17