package models import ( "crypto/hmac" "crypto/sha1" "encoding/base64" "net/url" ) func Sha1(query string, pri_key string) string { key := []byte(pri_key) mac := hmac.New(sha1.New, key) mac.Write([]byte(query)) query = base64.StdEncoding.EncodeToString(mac.Sum(nil)) query = url.QueryEscape(query) return query }
有疑问加站长微信联系(非本文作者)