TOTP {otp}R Documentation

Time based One Time Password (TOTP)

Description

An R6 class that implements the Time based One Time Password (TOTP) algorithm.

Initialization

TOTP$new(secret, digits = 6L, period = 30, algorithm = "sha1")

Create an One Time Password object

Methods

TOTP$at_time(t)

Generate an one time password at a given time value.

HOTP$verify(code, t, behind = 0L)

Verify if a given one time password is valid. Returns the beginning time of the time step window if there is a match within the behind window. Otherwise return NULL.

HOTP$provisioning_uri(name, issuer = NULL)

Return a provisioning uri which is compatible with google authenticator format.

See Also

https://datatracker.ietf.org/doc/html/rfc6238

Examples

p <- TOTP$new("JBSWY3DPEHPK3PXP")
(code <- p$now())
p$verify(code, behind = 1)

(current_time <- Sys.time())
(code <- p$at_time(current_time))
p$verify(code, current_time + 30, behind = 1)

p$provisioning_uri("Alice", issuer = "example.com")

[Package otp version 0.1.1 Index]