diff options
author | Andinus <andinus@nand.sh> | 2020-03-27 18:24:25 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-03-27 18:24:25 +0530 |
commit | 73952003142c7106482a198ce6024cba00c35e44 (patch) | |
tree | 0aa584c16e74addcfa13b825361b39ec21934070 /auth/token/generate.go | |
parent | ad9332dcd5912005917f4bf2f4c544115008138a (diff) | |
download | perseus-73952003142c7106482a198ce6024cba00c35e44.tar.gz |
Move token functions to its own package
Diffstat (limited to 'auth/token/generate.go')
-rw-r--r-- | auth/token/generate.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/auth/token/generate.go b/auth/token/generate.go new file mode 100644 index 0000000..0c717d9 --- /dev/null +++ b/auth/token/generate.go @@ -0,0 +1,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) +} |