@@ -272,7 +272,7 @@ func (srv *Server) handleRequest(w http.ResponseWriter, r *http.Request, isEncrp
272
272
nonce , signature , timestamp := query .Get ("nonce" ), query .Get ("signature" ), query .Get ("timestamp" )
273
273
274
274
// 检验消息是否来自微信服务器
275
- if encrypt .NewSigner (true , srv .token , timestamp , nonce ).CompareWith (signature ) {
275
+ if ! encrypt .NewSignable (true , srv .token , timestamp , nonce ).IsEqual (signature ) {
276
276
return nil , errors .New ("failed to validate signature" )
277
277
}
278
278
@@ -658,7 +658,7 @@ func (srv *Server) validateServer(req *http.Request) bool {
658
658
signature := query .Get ("signature" )
659
659
timestamp := query .Get ("timestamp" )
660
660
661
- return encrypt .NewSigner (true , nonce , timestamp , srv .token ).CompareWith (signature )
661
+ return encrypt .NewSignable (true , nonce , timestamp , srv .token ).IsEqual (signature )
662
662
}
663
663
664
664
// 加密消息
@@ -679,7 +679,7 @@ func (srv *Server) encryptMsg(message string, timestamp int64) (*EncryptedMsgReq
679
679
timestr := strconv .FormatInt (timestamp , 10 )
680
680
681
681
//生成安全签名
682
- signature := encrypt .NewSigner (true , srv .token , timestr , nonce , cipher ).Sign ()
682
+ signature := encrypt .NewSignable (true , srv .token , timestr , nonce , cipher ).Sign ()
683
683
request := EncryptedMsgRequest {
684
684
Nonce : nonce ,
685
685
Encrypt : cipher ,
0 commit comments