| Components | All | New | MacOS | Windows | Linux | iOS | ||||
| Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old | |
Hash.DigestFile
Calculates a hash of a file.
| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
| Hash | 9.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
MBS( "Hash.DigestFile"; Algorithm; FilePath; OutputType { ; OutputInfo; UpdateProgressbar } ) More
Parameters
| Parameter | Description | Example | Flags |
|---|---|---|---|
| Algorithm | Which algorithm to use. Can be MD4, MD5, SHA, SHA1, MDC2, RIPEMD160, SHA224, SHA256, SHA384 or SHA512. |
"SHA512" | |
| FilePath | The native file path to use. | "C:\test.dat" | |
| OutputType | The output type. Can be Base64, Hex, Text, File, Path. Added Base64URL as option for plugin version 10.3. |
"Hex" | |
| OutputInfo | The addition info for output. For text it is the text encoding, for file container the file name and for path the actual native file path. |
"" | Optional |
| UpdateProgressbar | Pass 1 to keep a progressbar updated for the digest in progress. Only useful for bigger files. |
1 | Optional Added in version 14.2. |
Result
Returns OK or error.
Description
Calculates a hash of a file.This function is optimized to process files on disk in chunks, so it works well for several GB of file sizes.
For output we can return the digest in various ways:
- Base64, the hash is returned as base64 encoded text.
- Hex, the hash is returned as hex encoded text.
Possible digest engines:
DSA-SHA, DSA, MD5, MDC2, RIPEMD160, SHA, SHA1, SHA224, SHA256, SHA384 or SHA512.
This function requires a native path. Use Path.FileMakerPathToNativePath to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use FileDialog functions.
For Server be aware that server has limited permissions and may not be able to access all files on a computer.
Examples
Create MD5 of file:
MBS("Hash.DigestFile"; "MD5"; "/Users/cs/Movies/test.mov"; "hex")
Hash a file with newer or older way:
#newer function:
Set Variable [$hash1; Value: MBS( "Hash.DigestFile"; "SHA256"; "/Users/cs/Desktop/test.xml"; "base64") ]
#older way:
Set Variable [$hash2; Value: MBS( "Hash.SHA256"; MBS("Text.ReadTextFile"; "/Users/cs/Desktop/test.xml"; "UTF-8"); 1)]
Set Variable [$hash1; Value: MBS( "Hash.DigestFile"; "SHA256"; "/Users/cs/Desktop/test.xml"; "base64") ]
#older way:
Set Variable [$hash2; Value: MBS( "Hash.SHA256"; MBS("Text.ReadTextFile"; "/Users/cs/Desktop/test.xml"; "UTF-8"); 1)]
See also
Release notes
- Version 15.5
- Fixed ProgressDialog functions to work better if you run Hash.DigestFile and click cancel.
- Version 14.2
- Added parameter for Hash.DigestFile to update progress dialog.
- Version 10.3
- Added Base64URL as output option for RSA.Sign, CURL.ReceiveData, Files.ReadFile, Hash.DigestFile, Hash.Digest, Encryption.Cipher and for other functions as text encoding parameter.
- Version 9.2
- Added Hash.DigestFile function to calculate hashes of big files.
Example Databases
Blog Entries
- MBS FileMaker Plugin, version 15.5pr6
- MBS FileMaker Plugin, version 14.2pr1
- Combined Components with MBS FileMaker Plugin
- MBS FileMaker Plugin, version 10.3pr1
- Was gibt es neues bei MBS Version 9.2
- MBS FileMaker Plugin, version 9.2pr3
This function checks for a license.
Created 12nd April 2019, last changed 12nd March 2024