aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2019-12-13 18:08:26 +0000
committerr <r@freesoftwareextremist.com>2019-12-13 18:26:24 +0000
commit5e4da01c3ae3ae2e870faba9085d9d9213c01c29 (patch)
tree39d6f1e76b901549f194ddbac3c6cb82e0abd019 /util
downloadbloat-5e4da01c3ae3ae2e870faba9085d9d9213c01c29.tar.gz
bloat-5e4da01c3ae3ae2e870faba9085d9d9213c01c29.zip
Initial commit
Diffstat (limited to 'util')
-rw-r--r--util/rand.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/util/rand.go b/util/rand.go
new file mode 100644
index 0000000..8502521
--- /dev/null
+++ b/util/rand.go
@@ -0,0 +1,22 @@
+package util
+
+import (
+ "math/rand"
+)
+
+var (
+ runes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
+ runes_length = len(runes)
+)
+
+func NewRandId(n int) string {
+ data := make([]rune, n)
+ for i := range data {
+ data[i] = runes[rand.Intn(runes_length)]
+ }
+ return string(data)
+}
+
+func NewSessionId() string {
+ return NewRandId(24)
+}