Skip to content

Commit 437d240

Browse files
authored
Merge pull request #1160 from RRCAT920/update-zh-04.4.md
Update zh/04.4.md
2 parents 72d959b + 546b604 commit 437d240

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

zh/04.4.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
func login(w http.ResponseWriter, r *http.Request) {
2222
fmt.Println("method:", r.Method) //获取请求的方法
2323
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))
24+
timestamp := strconv.Itoa(time.Now().Nanosecond())
25+
hashWr := md5.New()
26+
hashWr.Write([]byte(timestamp))
27+
token := fmt.Sprintf("%x", hashWr.Sum(nil))
2828

2929
t, _ := template.ParseFiles("login.gtpl")
3030
t.Execute(w, token)

0 commit comments

Comments
 (0)