Yimaru-BackEnd/internal/pkgs/helpers/helpers.go

27 lines
478 B
Go

package helpers
import (
"fmt"
"math/rand/v2"
"github.com/google/uuid"
)
func GenerateID() string {
return uuid.New().String()
}
func GenerateOTP() string {
num := 100000 + rand.UintN(899999)
return fmt.Sprintf("%d", num) // 6 digit random number [100,000 - 999,999]
}
func GenerateFastCode() string {
const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var code string
for i := 0; i < 6; i++ {
code += string(letters[rand.UintN(uint(len(letters)))])
}
return code
}