https://github.com/alex-cos/codeverif
Generating and verifying one-time verification codes
https://github.com/alex-cos/codeverif
code golang verification
Last synced: about 1 month ago
JSON representation
Generating and verifying one-time verification codes
- Host: GitHub
- URL: https://github.com/alex-cos/codeverif
- Owner: alex-cos
- License: mit
- Created: 2025-12-21T15:17:57.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2026-05-03T21:06:56.000Z (about 2 months ago)
- Last Synced: 2026-05-03T23:19:05.955Z (about 2 months ago)
- Topics: code, golang, verification
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# codeverif
[](https://go.dev/)
[](https://github.com/alex-cos/codeverif/actions/workflows/test.yml)
[](https://github.com/alex-cos/codeverif/actions/workflows/lint.yml)
[](LICENSE)
[](https://goreportcard.com/report/github.com/alex-cos/codeverif)
**codeverif** is a secure and lightweight Go module for generating and verifying **one-time verification codes**.
It is designed for common authentication flows such as:
- Login verification
- Password reset
- Email confirmation
The module is backend-oriented and integrates naturally into REST APIs (Gin, Echo, net/http).
---
## โจ Features
- ๐ Cryptographically secure numeric codes
- โฑ Code expiration handling
- ๐ Limited verification attempts
- ๐งช Unit-tested
- ๐ REST API friendly
---
## ๐ฆ Installation
```bash
go get github.com/alex-cos/codeverif
```
---
## Example
```go
// create a codeverif for a 6 digits code available during 10 minutes with 3 attempts.
cv := codeverif.New(6, 10*time.Minute, 3)
code, err := cv.RequestCode("JohnDoe")
if err != nil {
return err
}
// Send the generated code by mail to the end user for verification
// Then when asked verified the entered code.
err = cv.VerifyCode("JohnDoe", code)
if err == nil {
// Code successfully verified
}
```