busybar / internal / services / helpers.go
helpers.go
Raw
package services

import (
	"crypto/rand"
	"encoding/hex"
)

func GenerateToken(length int) (string, error) {
	bytes := make([]byte, length)
	_, err := rand.Read(bytes)
	if err != nil {
		return "", err
	}
	return hex.EncodeToString(bytes), nil
}