diff options
Diffstat (limited to 'auth/genid.go')
-rw-r--r-- | auth/genid.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/auth/genid.go b/auth/genid.go new file mode 100644 index 0000000..fea7ac9 --- /dev/null +++ b/auth/genid.go @@ -0,0 +1,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) +} |