Library to generate TOTP/HOTP codes

otpgen

Library to generate TOTP/HOTP codes

Installation

go get -u github.com/grijul/otpgen

Usage

Here is a sample demonstration

package main

import (
	"fmt"

	"github.com/grijul/otpgen"
)

func main() {

	// Generate TOTP
	totp := otpgen.TOTP{
		Secret:    "testpass",
		Digits:    8,        //(optional) (default: 6)
		Algorithm: "SHA256", //(optional) (default: SHA1)
		Period:    45,       //(optional) (default: 30)
		UnixTime:  11111111, //(optional) (default: Current Unix Time)
	}

	if otp, err := totp.Generate(); err == nil {
		fmt.Println(otp)
	} else {
		fmt.Println(err.Error())
	}

	// Generate HOTP
	hotp := otpgen.HOTP{
		Secret:  "testsecret",
		Counter: 100, //(default: 0)
		Digits:  8,   //(optional) (default: 6)
	}

	if otp, err := hotp.Generate(); err == nil {
		fmt.Println(otp)
	} else {
		fmt.Println(err.Error())
	}
}

Licence

MIT

Similar Resources

A scraper to generate ASL Anki Cards

ASL Pro Video Downloader Directions In the same folder as asl-pro.exe: Create fi

Dec 22, 2021

A command-line tool to generate a DoorDash Developer JWT

make-doordash-jwt This simple CLI tool takes a DoorDash Access Key (a JSON object comprised of a developerId, key_id, and signing_secret) and creates

Feb 2, 2022

An authorization library that supports access control models like ACL, RBAC, ABAC in Golang

An authorization library that supports access control models like ACL, RBAC, ABAC in Golang

Casbin News: still worry about how to write the correct Casbin policy? Casbin online editor is coming to help! Try it at: https://casbin.org/editor/ C

Jan 2, 2023

Go-Guardian is a golang library that provides a simple, clean, and idiomatic way to create powerful modern API and web authentication.

❗ Cache package has been moved to libcache repository Go-Guardian Go-Guardian is a golang library that provides a simple, clean, and idiomatic way to

Dec 23, 2022

JSON Web Token library

About … a JSON Web Token (JWT) library for the Go programming language. Feature complete Full test coverage Dependency free Key management The API enf

Dec 19, 2022

Golang OAuth2 server library

OSIN Golang OAuth2 server library OSIN is an OAuth2 server library for the Go language, as specified at http://tools.ietf.org/html/rfc6749 and http://

Dec 23, 2022

A Go library for doing header-based OAuth over HTTP or HTTPS.

Installation goinstall github.com/alloy-d/goauth Usage import ( "github.com/alloy-d/goauth" "os" ) func someFuncThatDoesStuffWithOAuth() (er

Sep 2, 2020

A library for performing OAuth Device flow and Web application flow in Go client apps.

A library for performing OAuth Device flow and Web application flow in Go client apps.

oauth A library for Go client applications that need to perform OAuth authorization against a server, typically GitHub.com. Traditionally,

Dec 30, 2022

⛩️ Go library for protecting HTTP handlers with authorization bearer token.

G8, pronounced Gate, is a simple Go library for protecting HTTP handlers with tokens. Tired of constantly re-implementing a security layer for each

Nov 14, 2022
Oct 8, 2022
Yet another ykman Go lib for requesting OATH TOTP Multi-Factor Authentication Codes from Yubikey Devices

ykmangoath Ykman OATH TOTP with Go Yet another ykman Go lib for requesting OATH TOTP Multi-Factor Authentication Codes from Yubikey Devices. ?? Work-i

Jul 3, 2022
✨ Pretty TOTP manager in your terminal
✨ Pretty TOTP manager in your terminal

asunder Asunder, Sweet and Other Distress asunder is a small pretty command-line TOTP manager. Installation Binaries Download a binary from the releas

Dec 26, 2022
A tool to manage accounts and codes of Google Authenticator.

A tool to manage accounts and codes of Google Authenticator.

Sep 10, 2021
Codes from "Esquenta Full-Cycle" Golang live

Golang Full Cycle livestream This was implemented in last week live from "Esquenta Full-Cycle" who is a pre-event warm up for the real Full-Cycle Imer

Dec 6, 2021
Generate a generic library of 2FA tokens compatible with Google Authenticator

towfa Generate a generic library of 2FA tokens compatible with Google Authenticator go get -u github.com/golandscape/twofa $twofa "you secret" result:

Mar 23, 2022
Generate K8s RBAC policies based on e2e test runs

rbac-audit Have you ever wondered whether your controller actually needs all the permissions it has granted to it? Wonder no more! This repo contains

Aug 2, 2021
Utility to generate tokens to interact with GitHub API via GitHub App integration

GitHub App Authentication for integration with GitHub Introduction GitHub Apps are the officially recommended way to integrate with GitHub because of

Mar 16, 2022
Generate and verify JWT tokens with Trusted Platform Module (TPM)

golang-jwt for Trusted Platform Module (TPM) This is just an extension for go-jwt i wrote over thanksgiving that allows creating and verifying JWT tok

Oct 7, 2022
Generate and verify JWT tokens with PKCS-11

golang-jwt for PKCS11 Another extension for go-jwt that allows creating and verifying JWT tokens where the private key is embedded inside Hardware lik

Dec 5, 2022