Skip to content
/ otp Public

One Time Password Generation and Verification

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

randy3k/otp

Repository files navigation

One Time Password Generation and Verification

check codecov CRAN_Status_Badge

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.

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] "012318"
p$verify(code)
## [1] "2024-01-22 15:55:30 PST"
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.

About

One Time Password Generation and Verification

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published

Languages