Modify: use base64-URLEncoding to encode signature hash

This commit is contained in:
HFO4 2020-01-17 14:39:30 +08:00
parent 68d4a86166
commit 21ec3fc710

View file

@ -3,7 +3,7 @@ package auth
import (
"crypto/hmac"
"crypto/sha256"
"fmt"
"encoding/base64"
"io"
"strconv"
"strings"
@ -25,7 +25,7 @@ func (auth HMACAuth) Sign(body string, expires int64) string {
return ""
}
return fmt.Sprintf("%x", h.Sum(nil)) + ":" + expireTimeStamp
return base64.URLEncoding.EncodeToString(h.Sum(nil)) + ":" + expireTimeStamp
}
// Check 对给定Body和Sign进行鉴权包括对expires的检查