All Projects → xlzd → Gotp

xlzd / Gotp

Licence: mit
Golang OTP(One-Time Password) Library.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Labels

Projects that are alternatives of or similar to Gotp

Aegis
A free, secure and open source app for Android to manage your 2-step verification tokens.
Stars: ✭ 2,692 (+1055.36%)
Mutual labels:  otp
Office Tool
© 2016-2021 Yerong. All Rights Reserved.
Stars: ✭ 3,657 (+1469.53%)
Mutual labels:  otp
Svpinview
SVPinView is a light-weight customisable library used for accepting pin numbers or one-time passwords.
Stars: ✭ 197 (-15.45%)
Mutual labels:  otp
Android Otp Extractor
Extracts OTP tokens from rooted Android devices
Stars: ✭ 147 (-36.91%)
Mutual labels:  otp
Otpview
A custom view to enter otp/pin of different sizes used usually in cases of authentication.
Stars: ✭ 172 (-26.18%)
Mutual labels:  otp
React Otp Input
✔️ OTP Input Component for React
Stars: ✭ 177 (-24.03%)
Mutual labels:  otp
Otpauth
One Time Password (HOTP/TOTP) library for Node.js, Deno and browsers.
Stars: ✭ 135 (-42.06%)
Mutual labels:  otp
Nitrokey App
Nitrokey's Application (Win, Linux, Mac)
Stars: ✭ 210 (-9.87%)
Mutual labels:  otp
Multiotp
multiOTP open source strong two factor authentication PHP library, OATH certified, with TOTP, HOTP, Mobile-OTP, YubiKey, SMS, QRcode provisioning, etc.
Stars: ✭ 173 (-25.75%)
Mutual labels:  otp
Go Otp
Package go-otp implements one-time-password generators used in 2-factor authentication systems like RSA-tokens. Currently this supports both HOTP (RFC-4226), TOTP (RFC-6238) and Base32 encoding (RFC-3548) for Google Authenticator compatibility
Stars: ✭ 194 (-16.74%)
Mutual labels:  otp
Flutter pinput
🔥🚀 Flutter package to create Pin code input text field with every pixel customization possibility 🎨 with beautiful animations
Stars: ✭ 157 (-32.62%)
Mutual labels:  otp
Authorizer
Authorizer is a Password Manager for Android. It emulates an HID keyboard over USB and enters your credentials on your target device. Additionally it supports OTP 🔑📴
Stars: ✭ 172 (-26.18%)
Mutual labels:  otp
Cuneiform
Cuneiform distributed programming language
Stars: ✭ 175 (-24.89%)
Mutual labels:  otp
Gen rmq
Elixir AMQP consumer and publisher behaviours
Stars: ✭ 146 (-37.34%)
Mutual labels:  otp
Twofactor totp
🔑 Second factor TOTP (RFC 6238) provider for Nextcloud
Stars: ✭ 203 (-12.88%)
Mutual labels:  otp
Yubikey Manager Qt
Cross-platform application for configuring any YubiKey over all USB interfaces.
Stars: ✭ 137 (-41.2%)
Mutual labels:  otp
React Native Sms Retriever
Android SMS Retriever API for React Native.
Stars: ✭ 177 (-24.03%)
Mutual labels:  otp
Freeotpplus
Enhanced fork of FreeOTP-Android providing a feature-rich 2FA authenticator
Stars: ✭ 223 (-4.29%)
Mutual labels:  otp
Otpclient
Highly secure and easy to use OTP client written in C/GTK that supports both TOTP and HOTP
Stars: ✭ 206 (-11.59%)
Mutual labels:  otp
Otp cheatsheet
Base OTP behaviors presented as schemas
Stars: ✭ 190 (-18.45%)
Mutual labels:  otp

GOTP - The Golang One-Time Password Library

build-status MIT License

GOTP is a Golang package for generating and verifying one-time passwords. It can be used to implement two-factor (2FA) or multi-factor (MFA) authentication methods in anywhere that requires users to log in.

Open MFA standards are defined in RFC 4226 (HOTP: An HMAC-Based One-Time Password Algorithm) and in RFC 6238 (TOTP: Time-Based One-Time Password Algorithm). GOTP implements server-side support for both of these standards.

GOTP was inspired by PyOTP.

Installation

$ go get github.com/xlzd/gotp

Usage

Check API docs at https://godoc.org/github.com/xlzd/gotp

Time-based OTPs

totp := gotp.NewDefaultTOTP("4S62BZNFXXSZLCRO")
totp.Now()  // current otp '123456'
totp.At(1524486261)  // otp of timestamp 1524486261 '123456'

# OTP verified for a given timestamp
totp.Verify('492039', 1524486261)  // true
totp.Verify('492039', 1520000000)  // false

// generate a provisioning uri
totp.ProvisioningUri("demoAccountName", "issuerName")
// otpauth://totp/issuerName:demoAccountName?secret=4S62BZNFXXSZLCRO&issuer=issuerName

Counter-based OTPs

hotp := gotp.NewDefaultHOTP("4S62BZNFXXSZLCRO")
hotp.At(0)  // '944181'
hotp.At(1)  // '770975'

# OTP verified for a given timestamp
hotp.Verify('944181', 0)  // true
hotp.Verify('944181', 1)  // false

// generate a provisioning uri
hotp.ProvisioningUri("demoAccountName", "issuerName", 1)
// otpauth://hotp/issuerName:demoAccountName?secret=4S62BZNFXXSZLCRO&counter=1&issuer=issuerName

Generate random secret

secretLength := 16
gotp.RandomSecret(secretLength) // LMT4URYNZKEWZRAA

Google Authenticator Compatible

GOTP works with the Google Authenticator iPhone and Android app, as well as other OTP apps like Authy. GOTP includes the ability to generate provisioning URIs for use with the QR Code scanner built into these MFA client apps via otpObj.ProvisioningUri method:

gotp.NewDefaultTOTP("4S62BZNFXXSZLCRO").ProvisioningUri("demoAccountName", "issuerName")
// otpauth://totp/issuerName:demoAccountName?secret=4S62BZNFXXSZLCRO&issuer=issuerName


gotp.NewDefaultHOTP("4S62BZNFXXSZLCRO").ProvisioningUri("demoAccountName", "issuerName", 1)
// otpauth://hotp/issuerName:demoAccountName?secret=4S62BZNFXXSZLCRO&counter=1&issuer=issuerName

This URL can then be rendered as a QR Code which can then be scanned and added to the users list of OTP credentials.

Working example

Scan the following barcode with your phone's OTP app (e.g. Google Authenticator):

Demo

Now run the following and compare the output:

package main

import (
	"fmt"
	"github.com/xlzd/gotp"
)

func main() {
	fmt.Println("Current OTP is", gotp.NewDefaultTOTP("4S62BZNFXXSZLCRO").Now())
}

License

GOTP is licensed under the MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].