summaryrefslogtreecommitdiff
path: root/utils.go
diff options
context:
space:
mode:
authorSteven Le Rouzic <steven.lerouzic@gmail.com>2024-04-21 01:24:47 +0200
committerSteven Le Rouzic <steven.lerouzic@gmail.com>2024-04-21 01:24:47 +0200
commit6e3c40ccb5597a93c3e9d9b4766005c6de424f85 (patch)
tree8a7e2262559e859cf1aed3ede95eeb6d52e62de2 /utils.go
parente7800492c36efffc373c0926a8962b4eff768a4e (diff)
Start of big cleanup
Diffstat (limited to 'utils.go')
-rw-r--r--utils.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/utils.go b/utils.go
new file mode 100644
index 0000000..5aa2894
--- /dev/null
+++ b/utils.go
@@ -0,0 +1,15 @@
+package main
+
+import (
+ "crypto/rand"
+ "encoding/base64"
+)
+
+func GenerateRandomString(len int) (string, error) {
+ bin := make([]byte, len)
+ _, err := rand.Read(bin)
+ if err != nil {
+ return "", err
+ }
+ return base64.StdEncoding.EncodeToString(bin), nil
+}