diff options
Diffstat (limited to 'utils.go')
| -rw-r--r-- | utils.go | 18 |
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[:]) +} |
