Browse Source

修改aes panic错误

fancl 1 year ago
parent
commit
bdc67c60d7
2 changed files with 7 additions and 3 deletions
  1. 5 1
      helper/crypto/aes.go
  2. 2 2
      request.go

+ 5 - 1
helper/crypto/aes.go

@@ -16,7 +16,11 @@ func PKCS7Padding(ciphertext []byte, blockSize int) []byte {
 func PKCS7UnPadding(origData []byte) []byte {
 	m := len(origData)
 	n := int(origData[m-1])
-	return origData[:(m - n)]
+	if m > n {
+		return origData[:(m - n)]
+	} else {
+		return origData
+	}
 }
 
 func AesEncrypt(buf, key []byte) ([]byte, error) {

+ 2 - 2
request.go

@@ -11,12 +11,12 @@ type (
 	}
 )
 
-//Do do request
+//Do handle request
 func (r *Request) Do(ctx context.Context) (Response, error) {
 	return r.client.Do(ctx, r)
 }
 
-//Call call method
+//Call execute method
 func (r *Request) Call(ctx context.Context, i interface{}) (err error) {
 	var (
 		res Response