Documentation
¶
Overview ¶
Package credvault provides encryption/decryption for credential secrets. It supports multiple algorithms via EncryptionType enum, with XChaCha20-Poly1305 as the recommended default.
Index ¶
- Constants
- Variables
- type EncryptionType
- type Vault
- func (v *Vault) Decrypt(ciphertext []byte, encType EncryptionType) ([]byte, error)
- func (v *Vault) DecryptString(ciphertext []byte, encType EncryptionType) (string, error)
- func (v *Vault) Encrypt(plaintext []byte, encType EncryptionType) ([]byte, error)
- func (v *Vault) EncryptString(plaintext string, encType EncryptionType) ([]byte, error)
Constants ¶
const (
// KeySize is the required size for the master encryption key (256-bit).
KeySize = 32
)
Variables ¶
Functions ¶
This section is empty.
Types ¶
type EncryptionType ¶
type EncryptionType = int8
EncryptionType specifies the algorithm used to encrypt credential secrets.
const ( EncryptionNone EncryptionType = 0 // Plaintext (no encryption) EncryptionXChaCha20Poly1305 EncryptionType = 1 // XChaCha20-Poly1305 AEAD (recommended) EncryptionAES256GCM EncryptionType = 2 // AES-256-GCM AEAD )
type Vault ¶
type Vault struct {
// contains filtered or unexported fields
}
Vault handles encryption and decryption of credential secrets.
func New ¶
New creates a new Vault with the given master key. The key must be exactly 32 bytes (256-bit).
func NewDefault ¶
func NewDefault() *Vault
NewDefault creates a Vault with a static all-zeros key. Good for obfuscation (not plaintext), but not cryptographically secure.
func (*Vault) Decrypt ¶
func (v *Vault) Decrypt(ciphertext []byte, encType EncryptionType) ([]byte, error)
Decrypt decrypts ciphertext using the specified encryption type. For EncryptionNone, returns the ciphertext unchanged.
func (*Vault) DecryptString ¶
func (v *Vault) DecryptString(ciphertext []byte, encType EncryptionType) (string, error)
DecryptString is a convenience method for decrypting to a string.
func (*Vault) Encrypt ¶
func (v *Vault) Encrypt(plaintext []byte, encType EncryptionType) ([]byte, error)
Encrypt encrypts plaintext using the specified encryption type. For EncryptionNone, returns the plaintext unchanged.
func (*Vault) EncryptString ¶
func (v *Vault) EncryptString(plaintext string, encType EncryptionType) ([]byte, error)
EncryptString is a convenience method for encrypting strings.