package main
import (
"crypto/md5"
"fmt"
"io"
"strconv"
"time"
)
func main() {
crutime := time.Now().Unix()
fmt.Println("crutime-->", crutime)
h := md5.New()
fmt.Println("h-->", h)
fmt.Println("strconv.FormatInt(crutime, 10)-->", strconv.FormatInt(crutime, 10))
io.WriteString(h, strconv.FormatInt(crutime, 10))
fmt.Println("h-->", h)
token := fmt.Sprintf("%x", h.Sum(nil))
fmt.Println("token--->", token)
fmt.Println(len("8e1a188743c6077110da3c9778183031"))
}
查看原文:http://www.zoues.com/2016/10/27/golang-%e4%bd%bf%e7%94%a8%e6%97%b6%e9%97%b4%e9%80%9a%e8%bf%87md5%e7%94%9f%e6%88%90token/
有疑问加站长微信联系(非本文作者)