From c2c39cc2756230c1de29d8065b8b320f2f084045 Mon Sep 17 00:00:00 2001 From: Thibaut Horel Date: Sat, 19 Nov 2016 17:35:07 -0500 Subject: Initial commit --- utils.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 utils.go (limited to 'utils.go') 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[:]) +} -- cgit v1.2.3-70-g09d2