https://github.com/mcaimi/go-hotp
Simple HOTP generation library written in Go
https://github.com/mcaimi/go-hotp
Last synced: 3 months ago
JSON representation
Simple HOTP generation library written in Go
- Host: GitHub
- URL: https://github.com/mcaimi/go-hotp
- Owner: mcaimi
- License: gpl-3.0
- Created: 2023-03-24T07:45:08.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-11T16:56:14.000Z (over 2 years ago)
- Last Synced: 2025-03-06T10:22:09.520Z (over 1 year ago)
- Language: Go
- Size: 22.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple HOTP Library written in Go
This is a simple HOTP library that implements the HOTP algorithm described in RFC4226.
The main HOTP function implements token generation following the rfc implementation (SHA-1 based HMAC) but the underlying HotpToken function can accept different HMAC functions.
## Usage
Simply import the library and use the preferred hashing function:
```Go
package main
import (
"fmt"
"encoding/hex"
"github.com/mcaimi/go-hotp/rfc4226"
)
const (
KEY = "3132333435363738393031323334353637383930"
INTERVAL = 0
)
func main() {
var token uint32
key, err := hex.DecodeString(KEY);
if err != nil {
fmt.Println(err);
} else {
token = rfc4226.Hotp(key, INTERVAL, 6, "sha1");
fmt.Printf("%d\n", token);
}
}
```