diff options
author | Andinus <andinus@nand.sh> | 2020-03-29 16:10:59 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-03-29 16:10:59 +0530 |
commit | a6826055bf4e6a23f80da047ccfe4509a209f3a6 (patch) | |
tree | f2bb2bec35ee5e61cb42f4edffb04368a0f8ba60 /password/randstr.go | |
parent | 7b95d6b80dd2d1efb26f7c515383abd4f0dc9d42 (diff) | |
download | perseus-a6826055bf4e6a23f80da047ccfe4509a209f3a6.tar.gz |
Initial perseus rewrite
Diffstat (limited to 'password/randstr.go')
-rw-r--r-- | password/randstr.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/password/randstr.go b/password/randstr.go new file mode 100644 index 0000000..86ae9a1 --- /dev/null +++ b/password/randstr.go @@ -0,0 +1,13 @@ +package password + +import ( + "crypto/rand" + "encoding/base64" +) + +// RandStr will return a random base64 encoded string of length n. +func RandStr(n int) string { + b := make([]byte, n/2) + rand.Read(b) + return base64.StdEncoding.EncodeToString(b) +} |