Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.5   7.0   7.1   7.2   7.3   7.4   7.5   8.0   8.1   8.2    Statistic  


Calculates a hash of a value.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
Hash 4.1 Yes Yes Yes Yes Yes

MBS( "Hash.Digest"; Algorithm; InputType; InputData; InputEncoding; OutputType; OutputInfo )


Parameter Description Example value
Algorithm Which algorithm to use.
Can be MD4, MD5, SHA, SHA1, MDC2, RIPEMD160, SHA224, SHA256, SHA384 or SHA512.
InputType The type of input.
Can be Text, Container, Image, Path, PDF, Data, base64 or Hex.
InputData The actual input data.
Text, container or file path.
"Hello World"
InputEncoding The text encoding for text input.
Parameter is ignored for other cases.
Possible encoding names: ANSI, Arabic-Mac, Arabic-Win, Baltic-Win, CentralEurope-Mac, ChineseSimp-Mac, ChineseSimp-Win, ChineseTrad-Mac, ChineseTrad-Win, Cyrillic-Mac, Cyrillic-Win, EasternEurope-Win, Greek-Mac, Greek-Win, Hebrew-Mac, Hebrew-Win, ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-15, Korean-Johab, Korean-Mac, Korean-Win, Latin1, Mac, Native, ShiftJIS-Mac, ShiftJIS-Win, Turkish-Mac, Turkish-Win, UTF-8, DOS or Windows. Pass native to use the native encoding of the current platform.
OutputType The output type.
Can be Base64, Hex, Text, File, Path.
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.


Returns error or hash.


Calculates a hash of a value.
Input can be one of different types:
Now for output we can return the digest in various ways:

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.


Calculate MD5 from text:

MBS( "Hash.Digest"; "MD5"; "Text"; "Hello World"; "UTF-8"; "Hex"; "" )

Calculate SHA512 from image in container and encode it as base64:

MBS( "Hash.Digest"; "SHA512"; "Image"; MyTable::MyContainer; ""; "Base64"; "" )

Hash of PDF in container:

MBS( "Hash.Digest"; "SHA512"; "PDF"; MyTable::MyContainer; ""; "Hex"; "" )

Hash a file with MD5:

MBS( "Hash.Digest"; "MD5"; "Path"; "/Users/cs/Desktop/test.fmp12"; ""; "Hex"; "" )

Stream file to AWS:

# Build a path to file (local) and in AWS
Set Variable [ $Filename ; Value: "test.pdf" ]
Set Variable [ $Path ; Value: "/" & $BucketName & "/PDF/" & $Filename ]
Set Variable [ $localPath ; Value: "/Users/cs/Desktop/license.pdf" ]
# calculate hash for file to upload
Set Variable [ $HashedPayload ; Value: Lower(MBS( "Hash.Digest"; "sha256"; "path"; $localPath; ""; "hex" )) ]
# upload
Set Variable [ $curl ; Value: MBS("CURL.New") ]
# file content is streamed
Set Variable [ $result ; Value: MBS("CURL.OpenInputFile"; $curl; $localPath) ]
# setup AWS
Set Variable [ $result ; Value: MBS("CURL.SetupAWS"; $curl; $AWSAccessKeyId; $AWSSecretAccessKey; $Region; $Service; $Path; $Domain; $Verb; $HashedPayload; $headers) ]
Set Field [ CURL Test::Result ; MBS("CURL.Perform"; $curl) ]
Set Field [ CURL Test::debug ; MBS("CURL.GetDebugAsText"; $curl) ]
Set Variable [ $result ; Value: MBS("CURL.Cleanup"; $curl) ]

See also

Example Databases

GetSystemUIModeOptions   -   Hash.MD5

Feedback: Report problem or ask question.

MBS FileMaker blog