diff options
| author | Thibaut Horel <thibaut.horel@gmail.com> | 2016-11-19 17:35:07 -0500 |
|---|---|---|
| committer | Thibaut Horel <thibaut.horel@gmail.com> | 2016-11-19 17:35:07 -0500 |
| commit | c2c39cc2756230c1de29d8065b8b320f2f084045 (patch) | |
| tree | baf3569f25b0fabeb93144d636bf61a2deae6b4a /utils.go | |
| download | lastfm-api-c2c39cc2756230c1de29d8065b8b320f2f084045.tar.gz | |
Initial commit
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[:]) +} |
