From cccfc05ea7b8bbd95dd21fb3e0ec98228fc22608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sun, 12 Feb 2023 00:00:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20jwt=20secret=20=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jwt.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jwt.go b/jwt.go index 2a88609..39f0160 100644 --- a/jwt.go +++ b/jwt.go @@ -38,7 +38,7 @@ func (j *ownJwt) Generate(signMethod jwt.SigningMethod, secret string, claims jw } else { token = jwt.NewWithClaims(signMethod, claims) } - return token.SignedString(secret) + return token.SignedString([]byte(secret)) } // Validate 验证token @@ -53,7 +53,7 @@ func (j *ownJwt) Validate(inputToken string, secret string) (jwt.Claims, error) ) if token, err = jwt.Parse(inputToken, func(tokenInfo *jwt.Token) (interface{}, error) { - return secret, nil + return []byte(secret), nil }); nil != err { return nil, errors.New("token parse fail : " + err.Error()) }