Github: https://github.com/randy3k/otp
Documentation: https://randy3k.github.io/otp
Generating and validating One-time Password based on Hash-based Message Authentication Code (HOTP) and Time Based One-time Password (TOTP) according to RFC 4226 https://datatracker.ietf.org/doc/html/rfc4226 and RFC 6238 https://datatracker.ietf.org/doc/html/rfc6238.
You can install the released version of otp from CRAN with:
install.packages("otp")
And the development version from GitHub with:
# install.packages("devtools")
::install_github("randy3k/otp") devtools
library(otp)
<- HOTP$new("JBSWY3DPEHPK3PXP")
p $at(8) p
## [1] "964230"
$verify("964230", 8) p
## [1] 8
<- TOTP$new("JBSWY3DPEHPK3PXP")
p <- p$now()) (code
## [1] "012318"
$verify(code) p
## [1] "2024-01-22 15:55:30 PST"
::image(
raster::qrencode_raster(p$provisioning_uri("otp")),
qrencoderasp = 1, col = c("white", "black"), axes = FALSE,
xlab = "", ylab = ""
)