我正在开发一个 web 服务器,在顶部我有import ("net/http" "log" "fmt" "encoding/json" "encoding/hex" "time" "math/rand" "crypto/sha256" "crypto/hmac" "strconv" "strings" "github.com/crowdmob/goamz/aws" "github.com/crowdmob/goamz/dynamodb")后来我有func singSomething(someid string) string {mac := hmac.New(sha256.New, key) mac.Write([]byte(id)) b := mac.Sum(nil)return hex.EncodeToString(b)}func validateSignature(id, signature string) bool {mac := hmac.New(sha256.New, key) mac.Write([]byte(id)) expectedMAC := mac.Sum(nil) signatureMAC, err := hex.DecodeString(signature) if err != nil { fmt.Println("PROBLEM IN DECODING HUH!") return false }return hmac.Equal(expectedMAC,signatureMAC)}当我发出时我收到这个错误 go run CSServer/CSServer.go:54: undefined: hmac.Equal为什么?到底是怎么回事?为什么hmac.New很好,但hmac.Equals不是?
2 回答
- 2 回答
- 0 关注
- 222 浏览
添加回答
举报
0/150
提交
取消