2 回答

TA貢獻(xiàn)1880條經(jīng)驗(yàn) 獲得超4個(gè)贊
謝謝正如你所說(shuō),我解決了這個(gè)問(wèn)題:
// 獲取驗(yàn)證碼圖片
func (this App) GetSecurityCode(timestamp int64) r.Result {
// 時(shí)間戳參數(shù),第一次加載為1,后續(xù)加載為當(dāng)前的時(shí)間戳,可以用來(lái)驗(yàn)證客戶(hù)端刷新頻率
// 如:刷新頻率過(guò)高,直接限制當(dāng)前客戶(hù)端等
//fmt.Println("GetSecurityCode", timestamp)
d := make([]byte, 4)
s := base.NewLen(4)
ss := ""
d = []byte(s)
for v := range d {
d[v] %= 10
ss += strconv.FormatInt(int64(d[v]), 32)
}
this.Session["securityCode"] = ss
fmt.Println(this.Session["securityCode"])
//this.Response.Status = http.StatusOK
//this.Response.ContentType = "image/png"
buff := &bytes.Buffer{}
base.NewImage(d, 100, 40).WriteTo(buff)
return this.RenderBinary(buff, "img", r.Attachment, time.Now())
}
- 2 回答
- 0 關(guān)注
- 200 瀏覽
添加回答
舉報(bào)