totp

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 9 Imported by: 0

README

A simple Time Based One-Time Password library

  • This library is created with the focus on simplicity and stable code.
  • This library will not change much once it will reach maturity.
  • While other implementations already exists, this project is mostly created because I was bored of building only websites :)
  • This library will try as much possible not to reinvent the wheel. If there is an implementation in the standard library, that implementation will be used. (I've seen in some other libraries this weird behavior of reinventing the wheel)

This implementation is based on RFC 6238

Project Goals & Roadmap

  1. Keep it simple
  2. Create a way of generating random secret keys (will be made soon)
  3. Implementing a method of generating the QR code for Google Authenticator and other similar apps like this.
  4. Keep it rock solid for years to come :)

Other things to keep in mind

  • The default behavior is to generate a code that will expire in 30 seconds
  • The generated code will have 6 numbers.

Maybe in the future I'm going to make it in a way to control this yourself, however this is not a priority.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TOTP

type TOTP struct {
	Key string
}

func (*TOTP) GenerateTOTP

func (totp *TOTP) GenerateTOTP(timestamp int64) (string, error)

Based from RFC 6238

func (*TOTP) Verify

func (totp *TOTP) Verify(inputCode string) bool

Verify if the given input code is valid for the current timestamp.

func (*TOTP) VerifyWithTimestamp

func (totp *TOTP) VerifyWithTimestamp(timestamp int64, inputCode string) bool

Verify if the input code is valid for a given timestamp. Use this just for testing

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL