Categorygithub.com/project-tech-3/numx
modulepackage
0.0.2
Repository: https://github.com/project-tech-3/numx.git
Documentation: pkg.go.dev

# README

NumX Library

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.

How To Install

To install the NumX library, run the following command:

go get github.com/project-tech-3/numx

How To Use

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 UUID V7
uuidStr,_,err := numx.GenerateUUIDV7()
if err != nil {
	fmt.Println("err Generate UUID V7: ",err.Error())
	return
}
fmt.Println("UUID V7: ", uuidStr)

//Get Time From UUID V7
timeUUID,_,err := numx.GetTimeFromUUIDV7(uuidStr)
if err != nil {
    fmt.Println("err Generate UUID V7: ",err.Error())
    return
}
fmt.Println("Time UUID V7: ", timeUUID)

// 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

Functions Overview

  • 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.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author