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.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4   7.5   8.0    Statistic  

Hash.SHA256.HMAC

Returns the a SHA256 HMAC based on the key and the data string.

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

MBS( "Hash.SHA256.HMAC"; key; data { ; Flags } )

Parameters

Parameter Description Example value
key The key text to use. "Hello"
data The data text to use. "World"
Flags Optional
Various flags you can combine by addition.
Pass 1 for getting result Base64 encoded instead of Hex encoded.
Pass 2 if key is Hex encoded and plugin should decode it first.
Pass 4 if data is hex encoded and plugin should decode it first.
0

Result

Returns the hash string.

Description

Returns the a SHA256 HMAC based on the key and the data string.
Keyed-Hash Message Authentication Code is a way to add salt to a hash for more security.

Please be aware that text can result in different hashes if it contains line endings. You may want to make sure that line endings are right with the Text.ReplaceNewline function before you compare hashes to results in other development tools. FileMaker uses Mac line endings by default and most examples for Javascript use Unix line endings.

Examples

Hash empty string

MBS( "Hash.SHA256.HMAC"; ""; "" )

Example result: B613679A0814D9EC772F95D778C35FC5FF1697C493715653C6C712144292C5AD

Hash a test string

MBS( "Hash.SHA256.HMAC"; "key"; "The quick brown fox jumps over the lazy dog")

Example result: F7BC83F430538424B13298E6AA6FB143EF4D59A14946175997479DBC2D1A3CD8

Hash with flags:

MBS( "Hash.SHA256.HMAC"; "6B6579"; "54686520717569636B2062726F776E20666F78206A756D7073206F76657220746865206C617A7920646F67"; 2+4)

Example result: F7BC83F430538424B13298E6AA6FB143EF4D59A14946175997479DBC2D1A3CD8

FileMaker 16 vs. Plugin:

# MBS Plugin:
MBS( "Hash.SHA256.HMAC"; "Key"; "Data")
# Same via FileMaker 16 native:
HexEncode( CryptAuthCode ( "Data" ; "SHA256" ; "Key" ))

See also


Hash.SHA256   -   Hash.SHA512

Feedback: Report problem or ask question.




Links
MBS FileMaker Plugins