This commit is contained in:
Leufolium 2024-07-28 18:04:00 +08:00
parent 341534b610
commit 67a5932e27
1 changed files with 4 additions and 1 deletions

View File

@ -74,7 +74,10 @@ func (cryptoService *CryptoService) EncryptByAES(msg []byte) (encryptedBytes []b
func (cryptoService *CryptoService) DecryptByAES(encryptedBytes []byte) (decryptedBytes []byte, err error) {
//CBC解密
block, _ := aes.NewCipher(cryptoService.aesPriKey) // 分组秘钥
block, err := aes.NewCipher(cryptoService.aesPriKey) // 分组秘钥
if err != nil {
return
}
blockSize := block.BlockSize() // 获取秘钥块的长度
blockMode := cipher.NewCBCDecrypter(block, cryptoService.aesPriKey[:blockSize]) // 加密模式
decryptedBytes = make([]byte, len(encryptedBytes)) // 创建数组