NumX is a simple Go library for generating unique IDs and One-Time Passwords (OTPs). This document provides instructions on how to install and use the library.
To install the NumX library, run the following command:
go get github.com/tss182/numx
Here’s a quick example of how to use the NumX library in your Go application:
// Generate ID From Time
genID := numx.GenerateID()
fmt.Println("Generated ID:", genID) // will generate ID based on time and random chars
// Transform ID to time.Time
timeID := numx.GetTimeFromID(genID) // genID is the ID from numx.GenerateID
fmt.Println("Time from ID:", timeID)
// Generate OTP
otp := numx.GetOtp(4) // 4 is the sample length for OTP
fmt.Println("Generated OTP:", otp) // will generate a 4-digit random number
- GenerateID(): Generates a unique ID.
- GetTimeFromID(id string): Converts the generated ID back to a
time.Time
object. - GetOtp(length int): Generates a One-Time Password of the specified length.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submi 5343 t a pull request for any improvements or bug fixes.