aboutsummaryrefslogtreecommitdiffstats
path: root/utils.go
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2016-11-19 17:35:07 -0500
committerThibaut Horel <thibaut.horel@gmail.com>2016-11-19 17:35:07 -0500
commitc2c39cc2756230c1de29d8065b8b320f2f084045 (patch)
treebaf3569f25b0fabeb93144d636bf61a2deae6b4a /utils.go
downloadlastfm-api-c2c39cc2756230c1de29d8065b8b320f2f084045.tar.gz
Initial commit
Diffstat (limited to 'utils.go')
-rw-r--r--utils.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/utils.go b/utils.go
new file mode 100644
index 0000000..cb29662
--- /dev/null
+++ b/utils.go
@@ -0,0 +1,18 @@
+package main
+
+import (
+ "crypto/md5"
+ "crypto/rand"
+ "encoding/hex"
+)
+
+func randomToken(length int) string {
+ b := make([]byte, length)
+ rand.Read(b)
+ return hex.EncodeToString(b)
+}
+
+func md5hex(s string) string {
+ hash := md5.Sum([]byte(s))
+ return hex.EncodeToString(hash[:])
+}