Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/randy3k/otp

One Time Password Generation and Verification
https://github.com/randy3k/otp

Last synced: 11 days ago
JSON representation

One Time Password Generation and Verification

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_knit$set(upload.fun = knitr::imgur_upload)
```

```{r results='asis', echo = FALSE, eval = TRUE}
d <- read.dcf("DESCRIPTION")
```

```{r results="asis", echo = FALSE, eval = TRUE}
title <- d[colnames(d) == "Title"]
cat(c("# ", paste(trimws(strsplit(title, "\n")[[1]]), collapse = " ")))
```

[![check](https://github.com/randy3k/otp/actions/workflows/check.yaml/badge.svg)](https://github.com/randy3k/otp/actions/workflows/check.yaml)
[![codecov](https://codecov.io/gh/randy3k/otp/branch/master/graph/badge.svg)](https://app.codecov.io/gh/randy3k/otp)
[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/otp)](https://cran.r-project.org/package=otp)
[![](http://cranlogs.r-pkg.org/badges/grand-total/otp)](https://cran.r-project.org/package=otp)

Github: [https://github.com/randy3k/otp](https://github.com/randy3k/otp)

Documentation: [https://randy3k.github.io/otp](https://randy3k.github.io/otp/)

```{r results="asis", echo = FALSE, eval = TRUE}
cat(d[colnames(d) == "Description"])
```

## Installation

You can install the released version of otp from [CRAN](https://CRAN.R-project.org) with:

``` r
install.packages("otp")
```

And the development version from [GitHub](https://github.com/) with:

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

```{r}
library(otp)
```

### HMAC based One Time Password (HOTP)

```{r}
p <- HOTP$new("JBSWY3DPEHPK3PXP")
p$at(8)
p$verify("964230", 8)
```

### Time based One Time Password (TOTP)

```{r}
p <- TOTP$new("JBSWY3DPEHPK3PXP")
(code <- p$now())
p$verify(code)
```

```{r, out.width = "20%"}
raster::image(
qrencoder::qrencode_raster(p$provisioning_uri("otp")),
asp = 1, col = c("white", "black"), axes = FALSE,
xlab = "", ylab = ""
)
```

## Related projects

- Ruby's [rotp](https://github.com/mdp/rotp).
- Python's [pyotp](https://github.com/pyauth/pyotp).
- [ropt](https://github.com/wrathematics/rotp), an R library for client side one time password management.