Hash.DigestFile
---------------

Calculates a hash of a file.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Hash](component_Hash.md) | [9.2](newinversion92.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Hash.DigestFile"; Algorithm; FilePath; OutputType { ; OutputInfo; UpdateProgressbar } ) 

**MBS**( **"Hash.DigestFile";** /\* Calculates a hash of a file. \*/  
**$Algorithm**; /\* Which algorithm to use.   
Can be MD4, MD5, SHA, SHA1, MDC2, RIPEMD160, SHA224, SHA256, SHA384 or SHA512.e.g. "SHA512" \*/   
**$FilePath**; /\* The native file path to use.e.g. "C:\\test.dat" \*/   
**$OutputType**; /\* The output type.   
Can be Base64, Hex, Text, File, Path.  
Added Base64URL as option for plugin version 10.3.e.g. "Hex" \*/   
**$OutputInfo**; /\* Optional; 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.e.g. "" \*/   
**$UpdateProgressbar**) /\* Optional; Pass 1 to keep a progressbar updated for the digest in progress.  
Only useful for bigger files.e.g. 1 \*/ 

### 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](PathFileMakerPathToNativePath.md) 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](component_FileDialog.md) 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](HashSHA256.md)"; MBS ("[Text.ReadTextFile](TextReadTextFile.md)"; "/Users/cs/Desktop/test.xml"; "UTF-8"); 1)\]  
### See also

- [Hash.Digest](HashDigest.md)
- [Hash.SHA256](HashSHA256.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)
- [Text.ReadTextFile](TextReadTextFile.md)

### Release notes

- **Version 16.1**
    - Improved [Hash.Digest](https://www.mbsplugins.eu/HashDigest.shtml) and [Hash.DigestFile](https://www.mbsplugins.eu/HashDigestFile.shtml) functions to work with shake128 and shake256.
- **Version 15.5**
    - Fixed [ProgressDialog](https://www.mbsplugins.eu/component_ProgressDialog.shtml) functions to work better if you run [Hash.DigestFile](https://www.mbsplugins.eu/HashDigestFile.shtml) and click cancel.
- **Version 14.2**
    - Added parameter for [Hash.DigestFile](https://www.mbsplugins.eu/HashDigestFile.shtml) to update progress dialog.
- **Version 10.3**
    - Added Base64URL as output option for [RSA.Sign](https://www.mbsplugins.eu/RSASign.shtml), [CURL.ReceiveData](https://www.mbsplugins.eu/CURLReceiveData.shtml), [Files.ReadFile](https://www.mbsplugins.eu/FilesReadFile.shtml), [Hash.DigestFile](https://www.mbsplugins.eu/HashDigestFile.shtml), [Hash.Digest](https://www.mbsplugins.eu/HashDigest.shtml), [Encryption.Cipher](https://www.mbsplugins.eu/EncryptionCipher.shtml) and for other functions as text encoding parameter.
- **Version 9.2**
    - Added [Hash.DigestFile](http://www.mbsplugins.eu/HashDigestFile.shtml) function to calculate hashes of big files.

### Example Databases

- [Window/Progress Dialog](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Window/Progress%20Dialog.shtml#5ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 16.1pr5](https://www.mbsplugins.de/archive/2026-03-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 15.5pr6](https://www.mbsplugins.de/archive/2025-11-09/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 14.2pr1](https://www.mbsplugins.de/archive/2024-04-02/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Combined Components with MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2021-03-29/Combined_Components_with_MBS_F/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.3pr1](https://www.mbsplugins.de/archive/2020-06-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Was gibt es neues bei MBS Version 9.2](https://www.mbsplugins.de/archive/2019-07-16/Was_gibt_es_neues_bei_MBS_Vers/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 9.2pr3](https://www.mbsplugins.de/archive/2019-04-17/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 12nd April 2019 , last changed 12nd March 2024

  
[Hash.Digest](HashDigest.md) - [Hash.MD5](HashMD5.md)

[HTML Version](HashDigestFile.shtml)