New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

multi_factor_auth

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multi_factor_auth

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

MultiFactorAuth

A ruby library for generating one time passwords and QR Codes.

Installation

Add this line to your application's Gemfile:

gem 'multi_factor_auth'

And then execute:

$ bundle

Or install it yourself as:

$ gem install multi_factor_auth

Usage

Time based OTP's

totp = MultiFactorAuth::TOTP.new("base32secret3232", issuer: "My Service")
totp.now # => "492039"

# OTP verified for current time
totp.verify("492039") # => true
sleep 30
totp.verify("492039") # => false
totp.provisioning_uri("alice@google.com")

Counter based OTP's

hotp = MultiFactorAuth::HOTP.new("base32secretkey3232")
hotp.at(0) # => "260182"
hotp.at(1) # => "055283"
hotp.at(1401) # => "316439"

# OTP verified with a counter
hotp.verify("316439", 1401) # => true
hotp.verify("316439", 1402) # => false

Generating a Base32 Secret key

MultiFactorAuth::Base32.random_base32  # returns a 16 character base32 secret. Compatible with Google Authenticator

Generating a QR Code

totp = MultiFactorAuth::TOTP.new("base32secretkey3232")
qrcode = totp.qr_code("alice@google.com")
image = qrcode.as_png
svg = qrcode.as_svg
html = qrcode.as_html
string = qrcode.as_ansi
string = qrcode.to_s

Resources

  • QR Codes
  • Base32 Library
  • The Ruby One Time Password Library

Contributing

  • Fork the project
  • Send a pull request

License

Open source under the terms of the MIT License.

FAQs

Package last updated on 11 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc