Documentation ¶
Overview ¶
Package aes wraps the crypto/aes package cipher to provide compatibility with the Cipher interface defined under the Crypto package.
Package aes provides encryption and decryption functionalities using the AES algorithm.
Package aes provides encryption and decryption functionalities using the AES algorithm.
Index ¶
- Variables
- type CBC
- func (a *CBC) Decrypt(ctx context.Context, encryptedData []byte) (plainData []byte, err error)
- func (a *CBC) DecryptString(ctx context.Context, encryptedData string) (string, error)
- func (a *CBC) Encrypt(ctx context.Context, plainBlob []byte) ([]byte, error)
- func (a *CBC) EncryptString(ctx context.Context, data string) (string, error)
- type ECB
- type GCM
- func (a *GCM) Decrypt(ctx context.Context, encryptedData []byte) (plainData []byte, err error)
- func (a *GCM) DecryptString(ctx context.Context, encryptedText string) (string, error)
- func (a *GCM) Encrypt(ctx context.Context, plainBlob []byte) ([]byte, error)
- func (a *GCM) EncryptString(ctx context.Context, plainText string) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrBlockError = fmt.Errorf("cipher text is not a multiple of the block size")
ErrBlockError indicates that the cipher text is not a multiple of the block size.
var ErrIVLengthMismatch = fmt.Errorf("IV length is not matching with block size")
ErrIVLengthMismatch indicates an IV length mismatch with the block size.
var ErrInvalidKeyLength = fmt.Errorf("invalid key length")
ErrInvalidKeyLength indicates an invalid key length.
Functions ¶
This section is empty.
Types ¶
type CBC ¶
type CBC struct {
// contains filtered or unexported fields
}
CBC is a cipher block chaining mode implementation.
func NewCBC ¶
func NewCBC(ctx context.Context, log log.Log, key string, padder crypto.Padder, iv []byte) (*CBC, error)
NewCBC creates a new CBC instance with custom padding.
func NewCBCPKCS7 ¶
NewCBCPKCS7 creates a new CBC instance with PKCS7 padding.
func (*CBC) Decrypt ¶
Decrypt decrypts the given encryptedData using CBC mode and returns the original data.
func (*CBC) DecryptString ¶
DecryptString decrypts the given encryptedData string using CBC mode and returns the original string.
type ECB ¶
type ECB struct {
// contains filtered or unexported fields
}
ECB represents the Electronic Codebook (ECB) mode of AES encryption.
func NewECBPKC5 ¶
NewECBPKC5 creates a new ECB instance with PKCS7 padding.
func (*ECB) Decrypt ¶
Decrypt decrypts the given data using ECB mode and returns the decrypted data.
type GCM ¶
type GCM struct {
// contains filtered or unexported fields
}
GCM represents the Galois/Counter Mode (GCM) of AES encryption.
func (*GCM) Decrypt ¶
Decrypt decrypts the given data using GCM mode and returns the decrypted data.
func (*GCM) DecryptString ¶
DecryptString decrypts the given base64-encoded encrypted text using GCM mode and returns the decrypted string.