From WikiChip
Difference between revisions of "mirc/identifiers/$totp"
< mirc‎ | identifiers

(Add'l stuff)
Line 1: Line 1:
 
{{mirc title|$totp Identifier}}'''$totp''' returns  a TOTP (Time-based One-time Password) based on the specified parameters.
 
{{mirc title|$totp Identifier}}'''$totp''' returns  a TOTP (Time-based One-time Password) based on the specified parameters.
  
 +
See the Wikipedia page for TOTP for details.
  
 
== Synopsis ==
 
== Synopsis ==
<pre>$totp(key, time, hash, digits, timestep)</pre>
+
<pre>$totp(key, time, hash, digits, timestep)
 +
$totp(key[, time[, hash[, digits[, timestep]]]])
 +
</pre>
  
== Paramters ==
+
== 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 of either 16, 24 or 32 chars; or plain text; or it can also be in a Google Authenticator format ie lowercase with spaces.
+
* '''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
+
* '''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
+
* '''hash''' - optional, hashing algorithm, default to sha1 (Other possibles: md5, sha256, sha384, sha512 )
* '''digits''' - optional, number of digits, default to 6
+
* '''digits''' - optional, number of digits, default to 6 (Valid: 3 thru 9)
 
* '''timestep''' - optional, number of timestep, default to 30
 
* '''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 ==
 
== Properties ==
Line 16: Line 23:
  
 
== Example ==
 
== Example ==
<source lang="mIRC">None</source>
+
<source lang="mIRC">
 +
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)
 +
</source>
  
 
== Compatibility ==
 
== Compatibility ==
Line 22: Line 40:
  
 
== See Also ==
 
== See Also ==
{{mIRC|$hotp}}
+
{{collist
 
+
|count = 2
[[Category:mIRC identifiers]]
+
|style = width: 50%; display: inherit;
 +
|
 +
* {{mIRC|$hotp}}
 +
* {{mIRC|$encode}}
 +
* {{mIRC|$md5}}
 +
* {{mIRC|$sha1}}
 +
* {{mIRC|$sha256}}
 +
* {{mIRC|$sha384}}
 +
* {{mIRC|$sha512}}
 +
}}

Revision as of 02:12, 30 April 2018

$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