Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codenoid/elixir-two-factor-auth
Library for generating QR-Code, Random Secret and Verify Time Based Password
https://github.com/codenoid/elixir-two-factor-auth
2fa-security password security two-factor-authentication
Last synced: about 1 month ago
JSON representation
Library for generating QR-Code, Random Secret and Verify Time Based Password
- Host: GitHub
- URL: https://github.com/codenoid/elixir-two-factor-auth
- Owner: codenoid
- License: mit
- Created: 2019-05-06T22:25:59.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-20T17:26:54.000Z (about 4 years ago)
- Last Synced: 2024-10-02T06:20:22.874Z (about 2 months ago)
- Topics: 2fa-security, password, security, two-factor-authentication
- Language: Elixir
- Homepage:
- Size: 7.81 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
:bangbang: | This library is insecure and barery maintained, we suggest you to use [https://github.com/dashbitco/nimble_totp](https://github.com/dashbitco/nimble_totp)
:---: | :---# Elixir2fa
Library for generating QR-Code, Random Secret and Verify Time Based Password
## Installation
This package can be installed by adding `elixir2fa` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:elixir2fa, "~> 0.1.0"}
]
end
```## Usage
```
iex> secret = Elixir2fa.random_secret(16)
"HpJBFRtHjgIQJWIB"
iex> Elixir2fa.generate_qr("account_name", secret)
"https://chart.googleapis.com/chart?chs=200x200&cht=qr&chl=200x200&chld=M|0&cht=qr&chl=otpauth://totp/account_name?secret=HpJBFRtHjgIQJWIB" # scan via Google Authenticator, Authy, etc
iex> Elixir2fa.generate_totp(secret)
"573671" # compare with user token
```Some source code taken from :
* https://github.com/codenoid/elixir-two-factor-auth
* https://gist.github.com/ahmadshah/8d978bbc550128cca12dd917a09ddfb7
* https://github.com/SushiChain/crystal-two-factor-auth/blob/master/src/crystal-two-factor-auth.crDocumentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/elixir2fa](https://hexdocs.pm/elixir2fa).