Skip to content

octoi/totp-implementation-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

TOTP IMPLEMENTATION

A complete Time-based One-Time Password (TOTP) server. To learn and expierment with TOTP internals.

What is TOTP?

TOTP (RFC 6238) generates 6-digit codes that change every 30 seconds using:

6-digit code = HMAC-SHA1(secret, UnixTime/30)

API Endpoints

server runs on :8080

  1. Signup (Generate TOTP secret)
POST /signup
Body 
  username: "Username"

Response

{
  "username": "testuser",
  "otpauth_url": "otpauth://totp/TOTP-Example:testuser?secret=JBSWY3DPEHPK3PXP...",
  "secret_b32": "JBSWY3DPEHPK3PXP..."
}
  1. Verify Code
POST /verify-code
Body
  username: "testuser"
  code: "483920"

Response

{
  "username": "testuser",
  "valid": true,
  "current": "483920"
}

About

simple TOTP implementation using golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages