We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 72d959b + 546b604 commit 437d240Copy full SHA for 437d240
zh/04.4.md
@@ -21,10 +21,10 @@
21
func login(w http.ResponseWriter, r *http.Request) {
22
fmt.Println("method:", r.Method) //获取请求的方法
23
if r.Method == "GET" {
24
- crutime := time.Now().Unix()
25
- h := md5.New()
26
- io.WriteString(h, strconv.FormatInt(crutime, 10))
27
- token := fmt.Sprintf("%x", h.Sum(nil))
+ timestamp := strconv.Itoa(time.Now().Nanosecond())
+ hashWr := md5.New()
+ hashWr.Write([]byte(timestamp))
+ token := fmt.Sprintf("%x", hashWr.Sum(nil))
28
29
t, _ := template.ParseFiles("login.gtpl")
30
t.Execute(w, token)
0 commit comments