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

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

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