blob: cb29662445dd5397cd79dc01804e2660c7e2e0da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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[:])
}
|