aes

package
v6.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2024 License: MIT Imports: 11 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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.

View Source
var ErrIVLengthMismatch = fmt.Errorf("IV length is not matching with block size")

ErrIVLengthMismatch indicates an IV length mismatch with the block size.

View Source
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

func NewCBCPKCS7(ctx context.Context, log log.Log, key string, iv []byte) (*CBC, error)

NewCBCPKCS7 creates a new CBC instance with PKCS7 padding.

func (*CBC) Decrypt

func (a *CBC) Decrypt(ctx context.Context, encryptedData []byte) (plainData []byte, err error)

Decrypt decrypts the given encryptedData using CBC mode and returns the original data.

func (*CBC) DecryptString

func (a *CBC) DecryptString(ctx context.Context, encryptedData string) (string, error)

DecryptString decrypts the given encryptedData string using CBC mode and returns the original string.

func (*CBC) Encrypt

func (a *CBC) Encrypt(ctx context.Context, plainBlob []byte) ([]byte, error)

Encrypt encrypts the given plainBlob using CBC mode and returns the encrypted data.

func (*CBC) EncryptString

func (a *CBC) EncryptString(ctx context.Context, data string) (string, error)

EncryptString encrypts the given data string using CBC mode and returns the encrypted string.

type ECB

type ECB struct {
	// contains filtered or unexported fields
}

ECB represents the Electronic Codebook (ECB) mode of AES encryption.

func NewECB

func NewECB(ctx context.Context, key []byte, log log.Log, padder crypto.Padder) (*ECB, error)

NewECB creates a new ECB instance with custom padding.

func NewECBPKC5

func NewECBPKC5(ctx context.Context, key []byte, log log.Log) (*ECB, error)

NewECBPKC5 creates a new ECB instance with PKCS7 padding.

func (*ECB) Decrypt

func (a *ECB) Decrypt(ctx context.Context, data []byte) ([]byte, error)

Decrypt decrypts the given data using ECB mode and returns the decrypted data.

func (*ECB) Encrypt

func (a *ECB) Encrypt(ctx context.Context, data []byte) ([]byte, error)

Encrypt encrypts the given data using ECB mode and returns the encrypted data.

func (*ECB) EncryptString

func (a *ECB) EncryptString(ctx context.Context, plainText string) (string, error)

EncryptString encrypts the given plaintext string using ECB mode and returns the encrypted string.

type GCM

type GCM struct {
	// contains filtered or unexported fields
}

GCM represents the Galois/Counter Mode (GCM) of AES encryption.

func NewGCM

func NewGCM(ctx context.Context, log log.Log, key string) (*GCM, error)

NewGCM creates a new GCM instance with the given key.

func (*GCM) Decrypt

func (a *GCM) Decrypt(ctx context.Context, encryptedData []byte) (plainData []byte, err error)

Decrypt decrypts the given data using GCM mode and returns the decrypted data.

func (*GCM) DecryptString

func (a *GCM) DecryptString(ctx context.Context, encryptedText string) (string, error)

DecryptString decrypts the given base64-encoded encrypted text using GCM mode and returns the decrypted string.

func (*GCM) Encrypt

func (a *GCM) Encrypt(ctx context.Context, plainBlob []byte) ([]byte, error)

Encrypt encrypts the given data using GCM mode and returns the encrypted data.

func (*GCM) EncryptString

func (a *GCM) EncryptString(ctx context.Context, plainText string) (string, error)

EncryptString encrypts the given plaintext string using GCM mode and returns the encrypted string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL