Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
12.1
12.2
12.3
12.4
12.5
13.0
13.1
13.2
13.3
13.4
Statistic
FMM
Blog
Calculates a Time-based one-time password.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
TOTP | 12.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example | Flags |
---|---|---|---|
Key | The secret to use. | "12345678" | |
TimeNow | The current time. In seconds. |
MBS("TOTP.CurrentTime") | |
TimeStart | The start time. In seconds. |
0 | |
TimeStep | The step value defining the duration the code is valid. In Seconds. |
30 | |
DigitCount | The number of digits to generate. Ranges usually from 4 to 9. |
6 | |
Algorithm | Available in MBS FileMaker Plugin 12.5 or newer. The algorithm to use. Can be empty, SHA1, SHA256 or SHA512. Default is SHA1 if nothing is passed. |
"SHA1" | Optional |
DecodeBase32 | Available in MBS FileMaker Plugin 12.5 or newer. Whether the password is base32 encoded and should be decoded. |
1 | Optional |
Returns value or error.
Calculate a code:
Set Variable [$code; Value: MBS( "TOTP.Calculate"; "12345678"; MBS("TOTP.CurrentTime"); 0; 30; 6 ) ]
Test the function with SHA-1:
Let([
key = "12345678901234567890";
TimeNow = 59;
TimeStep = 30;
TimeStart = 0;
Digits = 8;
r = MBS( "TOTP.Calculate"; Key; TimeNow; TimeStart; TimeStep; Digits )
]; r)
Example result: 94287082
Test the function with SHA-256:
Let([
key = "12345678901234567890123456789012";
TimeNow = 59;
TimeStep = 30;
TimeStart = 0;
Digits = 8;
r = MBS( "TOTP.Calculate"; Key; TimeNow; TimeStart; TimeStep; Digits; "sha256" )
]; r)
Example result: 46119246
Test the function with SHA-512:
Let([
key = "1234567890123456789012345678901234567890123456789012345678901234";
TimeNow = 59;
TimeStep = 30;
TimeStart = 0;
Digits = 8;
r = MBS( "TOTP.Calculate"; Key; TimeNow; TimeStart; TimeStep; Digits; "sha512" )
]; r)
Example result: 90693936
Test with base32 decoding:
MBS("TOTP.Calculate"; "JBSWY3DPEHPK3PXP"; MBS("TOTP.CurrentTime"); 0; 30; 6; "SHA1")
This function is free to use.
Created 24th May 2022, last changed 14th October 2022