encryption

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package encryption provides AES-GCM encryption and decryption functions for securing sensitive credential data. It supports both the current GCM-based format and legacy CFB-based ciphertext for backward compatibility.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptValue

func DecryptValue(ciphertext []byte, key []byte) ([]byte, error)

DecryptValue decrypts ciphertext that was encrypted with EncryptValue. It automatically detects the encryption format: if the ciphertext starts with the "gcm1" prefix, it uses AES-GCM decryption; otherwise, it falls back to legacy CFB decryption for backward compatibility. The key must be 32 bytes (256 bits). Returns an error if decryption fails, the ciphertext is malformed, or authentication fails (for GCM).

func EncryptValue

func EncryptValue(value string, key []byte) ([]byte, error)

EncryptValue encrypts a plaintext string using AES-256-GCM authenticated encryption. The key must be 32 bytes (256 bits). The returned ciphertext includes a version prefix ("gcm1"), a random nonce, and the encrypted data with authentication tag. Returns an error if the key is invalid or if random nonce 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