Hash.SHA1.HMAC
--------------

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

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

MBS( "Hash.SHA1.HMAC"; Key; Data { ; Flags } ) 

**MBS**( **"Hash.SHA1.HMAC";** /\* Returns the a SHA1 HMAC based on the key and the data string. \*/  
**$Key**; /\* The key text to use.e.g. "Hello" \*/   
**$Data**; /\* The data text to use.e.g. "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.  
Pass 8 for base64URL encoding. (new in v10.3)e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Key | The key text to use. | "Hello" |  |
| Data | The data text to use. | "World" |  |
| Flags | 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.   Pass 8 for base64URL encoding. (new in v10.3) | 0 | Optional |

### Result

Returns the hash string.

### Description

Returns the a SHA1 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](TextReplaceNewLine.md) 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.SHA1.HMAC"; ""; "" )  
<small>  
Example result: FBDB1D1B18AA6C08324B7D64B71FB76370690E1D</small>Hash a test string

 MBS ( "Hash.SHA1.HMAC"; "key"; "The quick brown fox jumps over the lazy dog")  
<small>  
Example result: DE7C9B85B8B78AA6BC8A7A36F70A90701C9DB4D9</small>FileMaker 16 vs. Plugin:

 # MBS Plugin:   
Set Variable \[ $r1 ; Value: MBS ( "Hash.SHA1.HMAC"; "Key"; "Data") \]  
\# Same via FileMaker 16 native:   
Set Variable \[ $r2 ; Value: HexEncode( CryptAuthCode ( "Data" ; "SHA1" ; "Key" )) \]  
### See also

- [Hash.SHA1](HashSHA1.md)
- [Hash.SHA256.HMAC](HashSHA256HMAC.md)
- [Hash.SHA512.HMAC](HashSHA512HMAC.md)
- [Text.ReplaceNewLine](TextReplaceNewLine.md)

### Release notes

- **Version 10.3**
    - Added option for Base64URL encoding to [Hash.MD5](https://www.mbsplugins.eu/HashMD5.shtml), [Hash.MD5.HMAC](https://www.mbsplugins.eu/HashMD5HMAC.shtml), [Hash.SHA1](https://www.mbsplugins.eu/HashSHA1.shtml), [Hash.SHA1.HMAC](https://www.mbsplugins.eu/HashSHA1HMAC.shtml), [Hash.SHA256](https://www.mbsplugins.eu/HashSHA256.shtml), [Hash.SHA256.HMAC](https://www.mbsplugins.eu/HashSHA256HMAC.shtml), [Hash.SHA512](https://www.mbsplugins.eu/HashSHA512.shtml) and [Hash.SHA512.HMAC](https://www.mbsplugins.eu/HashSHA512HMAC.shtml) functions.

### Example Databases

- [CURL/WebServices/Twitter oAuth](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/WebServices/Twitter%20oAuth.shtml#5ScriptAnchor_)
- [Encryption and Hash/HMAC](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Encryption%20and%20Hash/HMAC.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 10.3pr1](https://www.mbsplugins.de/archive/2020-06-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Comparing Base Elements Plugin to MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2017-10-24/Comparing_Base_Elements_Plugin/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 6.0pr7](https://www.mbsplugins.de/archive/2016-01-20/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 3.2pr7](https://www.mbsplugins.de/archive/2013-04-16/MBS_Filemaker_Plugin_version_3/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 18th August 2014 , last changed 24th February 2026

  
[Hash.SHA1](HashSHA1.md) - [Hash.SHA256](HashSHA256.md)

[HTML Version](HashSHA1HMAC.shtml)