Browse Source

update aes

ls 3 weeks ago
parent
commit
34dd132971
1 changed files with 3 additions and 2 deletions
  1. 3 2
      crypto.go

+ 3 - 2
crypto.go

@@ -63,12 +63,13 @@ func (a *AesCrypto) Decrypt(crypted []byte) ([]byte, error) {
 	if err != nil {
 		return nil, err
 	}
+	n := len(crypted)
 	blockSize := block.BlockSize()
-	if len(crypted)%blockSize != 0 {
+	if n%blockSize != 0 {
 		return nil, errors.New(`crypto/cipher: input not full blocks`)
 	}
 	blockMode := cipher.NewCBCDecrypter(block, a.IV[:blockSize])
-	origData := make([]byte, len(crypted))
+	origData := make([]byte, n)
 	blockMode.CryptBlocks(origData, crypted)
 	origData = pkcs7UnPadding(origData)