package crypto

import (
	"encoding/base64"
	"strings"

	"github.com/pborman/uuid"
)

// SecureToken creates a new random token
func SecureToken() string {
	token := uuid.NewRandom()
	return removePadding(base64.URLEncoding.EncodeToString([]byte(token)))
}

func removePadding(token string) string {
	return strings.TrimRight(token, "=")
}

package crypto

import (
	"crypto/rand"
	"encoding/base64"
	"io"
	"strings"
)

// SecureToken creates a new random token
func SecureToken() string {
	b := make([]byte, 16)
	if _, err := io.ReadFull(rand.Reader, b); err != nil {
		panic(err.Error()) // rand should never fail
	}
	return removePadding(base64.URLEncoding.EncodeToString(b))
}

func removePadding(token string) string {
	return strings.TrimRight(token, "=")
}

Use rand.Reader directly instead of relying upon uuid
Use rand.Reader directly instead of relying upon uuid

uuid did some bit manipulation so actually only guaranteed 122 bits of random data. This change gets us the full 128 bits.
