aes

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const KeyLength = 32

KeyLength is the min length of the secret key

Variables

View Source
var (
	// ErrShortKey key is too short
	ErrShortKey = fmt.Errorf("key is too short, %d bytes is required", KeyLength)
)

Functions

func Decrypt

func Decrypt(data, key []byte) ([]byte, error)

Decrypt decrypts data using 256-bit AES-GCM, key must have length 32 or more

func DecryptBase64 added in v0.3.1

func DecryptBase64(ciphertext, key string) ([]byte, error)

DecryptBase64 decrypts a base64 form ciphertext to raw data([]byte) using 256-bit AES-GCM, key must have length 32 or more

func DecryptBase64String added in v0.2.0

func DecryptBase64String(ciphertext, key string) (string, error)

DecryptBase64String decrypts a base64 form ciphertext to the plaintext using 256-bit AES-GCM, key must have length 32 or more

func DecryptHex added in v0.3.1

func DecryptHex(ciphertext, key string) ([]byte, error)

DecryptHex decrypts a hex form ciphertext to raw data([]byte) using 256-bit AES-GCM, key must have length 32 or more

func DecryptHexString added in v0.2.0

func DecryptHexString(ciphertext, key string) (string, error)

DecryptHexString decrypts a hex form ciphertext to the plaintext using 256-bit AES-GCM, key must have length 32 or more

func Encrypt

func Encrypt(data, key []byte) ([]byte, error)

Encrypt encrypts data using 256-bit AES-GCM, key must have length 32 or more

func EncryptStringToBase64 added in v0.2.0

func EncryptStringToBase64(plaintext, key string) (string, error)

EncryptStringToBase64 encrypts plaintext to ciphertext (base64 form) using 256-bit AES-GCM, key must have length 32 or more

func EncryptStringToHex added in v0.2.0

func EncryptStringToHex(plaintext, key string) (string, error)

EncryptStringToHex encrypts plaintext to ciphertext (hex form) using 256-bit AES-GCM, key must have length 32 or more

func EncryptToBase64 added in v0.3.1

func EncryptToBase64(data []byte, key string) (string, error)

EncryptToBase64 encrypts data to ciphertext (base64 form) using 256-bit AES-GCM, key must have length 32 or more

func EncryptToHex added in v0.3.1

func EncryptToHex(data []byte, key string) (string, error)

EncryptToHex encrypts data to ciphertext (hex form) using 256-bit AES-GCM, key must have length 32 or more

Types

This section is empty.

Jump to

Keyboard shortcuts

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