Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
TOTP.Calculate
Calculates a Time-based one-time password.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
TOTP | 12.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
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 |
Result
Returns value or error.
Description
Calculates a Time-based one-time password.Uses SHA-1 as hash algorithm.
The result is returned as number and may miss leading zeros, if you just convert it to text.
Examples
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")
See also
Release notes
- Version 12.5
- Added algorithm and DecodeBase32 parameters to TOTP.Calculate function.
- Changed TOTP.Calculate function to return number with zeros on front.
- Version 12.3
- Added TOTP.Calculate function and TOTP.CurrentTime function to create Time-based one-time passwords.
Example Databases
Blog Entries
- Neues MBS Plugin 12.5 für Claris FileMaker
- MBS Plugin 12.5 for Claris FileMaker - More than 6800 Functions In One Plugin
- MBS FileMaker Plugin, version 12.5pr4
- MBS FileMaker Plugin, version 12.5pr3
- MBS FileMaker Plugin, version 12.5pr1
- MBS FileMaker Plugin 12.3
- Neues MBS Plugin 12.3 für Claris FileMaker
- MBS Plugin 12.3 for Claris FileMaker
- MBS FileMaker Plugin, version 12.3pr1
This function is free to use.
Created 24th May 2022, last changed 14th October 2022