XUtils

nimble_totp

Allows implementation of Time-based One-Time Passwords (TOTP) for 2FA.


NimbleTOTP

This library allows developers to implement Time-based One-Time Passwords (TOTP) for their applications as one of the mechanisms for Two-factor authentication (2FA).

It provides functions to:

  • Generate secrets composed of random bytes.
  • Generate URIs to be encoded in a QR Code.
  • Generate Time-Based One-Time Passwords for a secret.

Documentation can be found at https://hexdocs.pm/nimble_totp.

#=> <<63, 24, 42, 30, 95, 116, 80, 121, 106, 102>>


Generating a URI to be encoded in a QR Code:

```elixir
NimbleTOTP.otpauth_uri("Acme:alice", secret, issuer: "Acme")
#=> "otpauth://totp/Acme:alice?secret=MFRGGZA&issuer=Acme"

Generating a Time-Based One-Time Password for a secret and validating it:

NimbleTOTP.verification_code(secret)
#=> "569777"

NimbleTOTP.valid?(secret, "569777")
#=> true

Articles

  • coming soon...