瀏覽代碼

:edit 修改加密返回报文

fly 3 月之前
父節點
當前提交
1739616905
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      algorithm/encryption/AesCBCWithPadding.go

+ 2 - 2
algorithm/encryption/AesCBCWithPadding.go

@@ -49,9 +49,9 @@ func (a *AesCBCWithPadding) Encrypt(plaintext []byte) ([]byte, error) {
 	ciphertext := make([]byte, aes.BlockSize+len(plaintext))
 	copy(ciphertext[:aes.BlockSize], a.iv)
 	mode := cipher.NewCBCEncrypter(block, a.iv)
-	mode.CryptBlocks(ciphertext, plaintext)
+	mode.CryptBlocks(ciphertext[aes.BlockSize:], plaintext)
 
-	return ciphertext, nil
+	return ciphertext[aes.BlockSize:], nil
 }
 
 // AES解密函数