small pixel drawing of a pufferfish vore

lib/token.go

1 2 3 4 5 6 7 8 9 10 11 12 13 14
package lib

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

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