crypto

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SizeKey = 32
)

Variables

View Source
var (
	ErrVerifyKEy      = errors.New("err verify key on standard aes")
	ErrBlockCipher    = errors.New("err create 128-bit block cipher")
	ErrRandRead       = errors.New("err rand read encrypt")
	ErrAuthCiphertext = errors.New("err open decrypts and authenticates ciphertext")
	ErrGenerateKey    = errors.New("err generate key")
)

Functions

func Decrypt

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

Decrypt authenticates and decrypts ciphertext using: - Same key used for encryption - Embedded nonce from ciphertext Returns plaintext or error if decryption/authentication fails

func Encrypt

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

Encrypt securely encrypts plaintext using AES-GCM with: - Provided encryption key - Random nonce generation Returns ciphertext or error if encryption fails

func GenerateKey

func GenerateKey() (string, error)

GenerateKey creates a cryptographically secure: - 256-bit (32-byte) random key - Suitable for AES-256 encryption Returns key or error if random generation fails

Types

This section is empty.

Jump to

Keyboard shortcuts

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