• Stars
    star
    396
  • Rank 108,827 (Top 3 %)
  • Language
    Elixir
  • Created over 4 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A tiny Elixir library for time-based one time passwords (TOTP)

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.

Installation

You can install nimble_totp by adding it to your list of dependencies in mix.exs:

def deps do
  [
    {:nimble_totp, "~> 1.0"}
  ]
end

Usage

Generating a secret composed of random bytes:

secret = NimbleTOTP.secret()
#=> <<63, 24, 42, 30, 95, 116, 80, 121, 106, 102>>

Generating a URI to be encoded in a QR Code:

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

Nimble*

All nimble libraries by Dashbit:

  • NimbleCSV - simple and fast CSV parsing
  • NimbleOptions - tiny library for validating and documenting high-level options
  • NimbleParsec - simple and fast parser combinators
  • NimblePool - tiny resource-pool implementation
  • NimblePublisher - a minimal filesystem-based publishing engine with Markdown support and code highlighting
  • NimbleTOTP - tiny library for generating time-based one time passwords (TOTP)

License

Copyright 2020 Dashbit

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

broadway

Concurrent and multi-stage data ingestion and data processing with Elixir
Elixir
2,414
star
2

flow

Computational parallel flows on top of GenStage
Elixir
1,544
star
3

mox

Mocks and explicit contracts in Elixir
Elixir
1,343
star
4

nimble_parsec

A simple and fast library for text-based parser combinators
Elixir
807
star
5

nimble_csv

A simple and fast CSV parsing and dumping library for Elixir
Elixir
771
star
6

nimble_options

A tiny library for validating and documenting high-level options. πŸ’½
Elixir
505
star
7

nimble_publisher

A minimal filesystem-based publishing engine with Markdown support and code highlighting
Elixir
467
star
8

nimble_pool

A tiny resource-pool implementation for Elixir
Elixir
344
star
9

bytepack_archive

Archive of bytepack.io
Elixir
328
star
10

broadway_kafka

A Broadway connector for Kafka
Elixir
232
star
11

broadway_dashboard

Keep track of your Broadway pipelines from Phoenix LiveDashboard
Elixir
218
star
12

mix_phx_gen_auth_demo

Example repository for mix phx.gen.auth
Elixir
211
star
13

broadway_rabbitmq

A Broadway producer for RabbitMQ
Elixir
192
star
14

broadway_sqs

A Broadway producer for Amazon SQS
Elixir
92
star
15

broadway_cloud_pub_sub

A Broadway producer for Google Cloud Pub/Sub
Elixir
70
star
16

nimble_ownership

Elixir
55
star
17

broadway_bike_sharing_rabbitmq_example

An example of a Broadway pipeline for a bike sharing app with RabbitMQ and PostgreSQL
Elixir
50
star
18

nimble_strftime

A simple and fast strftime-based datetime formatter
Elixir
37
star
19

unpickler

A library for loading data in the Python's pickle format
Elixir
14
star
20

broadway_website

Landing page for the Elixir Broadway library.
HTML
6
star