Learn R Programming

⚠️There's a newer version (0.1.1) of this package.Take me there.

One Time Password Generation and Verification

Documentation: http://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://tools.ietf.org/html/rfc4226 and RFC 6238 https://tools.ietf.org/html/rfc6238.

Installation

You can install the released version of otp from CRAN with:

install.packages("otp")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("randy3k/otp")

Example

library(otp)

HMAC based One Time Password (HOTP)

p <- HOTP$new("JBSWY3DPEHPK3PXP")
p$at(8)
#> [1] "964230"
p$verify("964230", 8)
#> [1] 8

Time based One Time Password (TOTP)

p <- TOTP$new("JBSWY3DPEHPK3PXP")
(code <- p$now())
#> [1] "467326"
p$verify(code)
#> [1] "2020-04-30 21:59:30 PDT"
raster::image(
  qrencoder::qrencode_raster(p$provisioning_uri("otp")),
  asp = 1, col = c("white", "black"), axes = FALSE,
  xlab = "", ylab = ""
)

Related projects

  • Ruby’s rotp.
  • Python’s pyotp.
  • ropt, an R library for client side one time password management.

Copy Link

Version

Install

install.packages('otp')

Monthly Downloads

391

Version

0.1.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Randy Lai

Last Published

May 5th, 2020

Functions in otp (0.1.0)

TOTP

Time based One Time Password (TOTP)
HOTP

HMAC based One Time Password (HOTP)
otp-package

otp: One Time Password Generation and Verification