summary refs log tree commit diff stats
path: root/auth/token/generate.go
blob: 0c717d9b6bd75b4c84b4fc3389ddaea606f48855 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
package token

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

// genToken generates a random token string of length n. Don't forget to
// seed the random number generator otherwise it won't be random.
func genToken(n int) string {
	b := make([]byte, n/2)
	rand.Read(b)
	return base64.StdEncoding.EncodeToString(b)
}