Files
Authentication/helper/uuid_generator.go
T
2025-11-25 15:12:31 +08:00

22 lines
465 B
Go

package helper
import (
"crypto/rand"
"math/big"
)
const IDCharset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
const IDLength = 11
func UUIDGenerator() string {
ID := make([]byte, IDLength)
for i := 0; i < IDLength; i++ {
num, err := rand.Int(rand.Reader, big.NewInt(int64(len(IDCharset))))
if err != nil {
panic(err) // Handle error appropriately in production code
}
ID[i] = IDCharset[num.Int64()]
}
return string(ID)
}