enhance(crypto):包装AES算法中的错误提示。
This commit is contained in:
parent
3df5dbfd36
commit
2e276ca33c
|
@ -5,6 +5,7 @@ import (
|
|||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
|
||||
"archgrid.xyz/ag/toolsbox/encryption"
|
||||
)
|
||||
|
@ -36,7 +37,7 @@ func Encrypt(data []byte, key []byte, padding encryption.PaddingMode, ivGenerato
|
|||
keyBytes := generateKey(key)
|
||||
block, err := aes.NewCipher(keyBytes[:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("创建加密单元失败,%w", err)
|
||||
}
|
||||
iv := append(ivGenerator, XorIVGenerator)[0](keyBytes)
|
||||
plainText := encryption.Padding(data, block.BlockSize(), padding)
|
||||
|
@ -54,7 +55,7 @@ func Decrypt(data []byte, key []byte, padding encryption.PaddingMode, ivGenerato
|
|||
keyBytes := generateKey(key)
|
||||
block, err := aes.NewCipher(keyBytes[:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("创建加密单元失败,%w", err)
|
||||
}
|
||||
iv := append(ivGenerator, XorIVGenerator)[0](keyBytes)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user