From WikiChip
$totp Identifier - mIRC
< mirc‎ | identifiers
Revision as of 02:12, 30 April 2018 by Maroonbells (talk | contribs) (Add'l stuff)

$totp returns a TOTP (Time-based One-time Password) based on the specified parameters.

See the Wikipedia page for TOTP for details.

Synopsis

$totp(key, time, hash, digits, timestep)
$totp(key[, time[, hash[, digits[, timestep]]]])

Parameters

  • key - the key is required and can be in a base16 format of either 40, 64 or 128 chars; or in a base32 format (created using $encode) of either 16, 24 or 32 chars; or plain text; or it can also be in a Google Authenticator format ie lowercase with spaces.
  • time - optional, a time in second, default to $ctime ("in seconds" assumes that 'timestep' is also defined in seconds)
  • hash - optional, hashing algorithm, default to sha1 (Other possibles: md5, sha256, sha384, sha512 )
  • digits - optional, number of digits, default to 6 (Valid: 3 thru 9)
  • timestep - optional, number of timestep, default to 30
  • Note: "Optional" parameters are not allowed to be $null when defining later parameters.
  • Output number is the same for all "time" values where $int($calc(time / timestep)) is the same N value. An application allowing a "grace period" for recognizing tokens for multiple intervals must calculate result where time=time+timestep and time=time-timestep.

Properties

None

Example

Password changing every hour on-the-hour (long intervals are NOT recommended)
//echo -a $totp(Secret case-sensitive Pass Key,$ctime,sha512,9,3600)
 
recognize password reply for the current 30-sec interval plus the prior or following intervals. Uses defaults sha1, 6 digits, and 30 sec interval:
var %t1 $ctime , %t2 = $ctime + 30 , %t3 = $ctime - 30
var %totp1 $totp(Secret Key,%t1) , %totp2 $totp(Secret Key,%t2) , %totp3 $totp(Secret Key,%t3)
if ($istok(%totp1 %totp2 %totp3,%reply,32)) goto Accepted
 
For internal use only because $ticks is different for everyone, password changes every 60 seconds, but not necessarily at :00 seconds.
$totp(Secret Key,$ticks,sha256,9,60000)

Compatibility

Added: mIRC v7.42
Added on: 17 Jul 2015
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.


See Also