aes

package
v0.0.0-...-a264c11 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package aes provides encryption and decryption functions using the AES algorithm. It includes functions for generating AES keys, encrypting plaintext, and decrypting ciphertext.

The package uses AES-256 encryption in CBC mode with PKCS7 padding. Key generation pads or truncates the provided key to ensure it's always 32 bytes (256 bits).

Usage:

key := []byte("your-secret-key")
plaintext := "Hello, World!"

// Encrypt
encrypted, err := aes.Encrypt(plaintext, key)
if err != nil {
    // Handle error
}

// Decrypt
decrypted, err := aes.Decrypt(encrypted, key)
if err != nil {
    // Handle error
}

Note: Always use a secure method to generate and store your encryption keys. Never use hardcoded keys in production environments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(encrypted string, key []byte) (string, error)

Decrypt 使用AES-256解密数据

func Encrypt

func Encrypt(plaintext string, key []byte) (string, error)

Encrypt 使用AES-256加密数据

Types

This section is empty.

Jump to

Keyboard shortcuts

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