Name

TOTP_generate — Returns TOTP string Time-based One-time Password Generator (rfc6238)

Synopsis

varchar TOTP_generate ( in start_date datetime ,
in date datetime ,
in step integer ,
in return_digits integer ,
in key_name varchar ,
in digest_algo varchar );

Description

Returns TOTP string Time-based One-time Password Generator (rfc6238).

Parameters

start_date

T0 (zero time, usually 1970-1-1) .

date

The current time ex. now () .

step

Time step in secconds, usually 30.

return_digits

How much digits to return, from 1 to 8.

key_name

The key name keeping secret. Note: when setting up the key, should use 20 bytes for hmac-sha1, 32 bytes for hmac-sha256. Also the systems that are used for TOTP should have time synchronized.

digest_algo

string, one of hmac-sha1 or hmac-sha256 .

Return Types

On success the function will return TOTP string Time-based One-time Password Generator (rfc6238).

Examples

Example24.461.

 xenc_key_RAW_read ('k2', encode_base64 (cast (hex2bin ('3132333435363738393031323334353637383930313233343536373839303132') as varchar)));
 select TOTP_generate (stringdate ('1970-01-01Z'), stringdate ('2603-10-11 11:33:20Z'), 30, 8, 'k2', 'hmac-sha256');