Documentation
¶
Overview ¶
Package crypto provides encryption and decryption for sensitive data.
Index ¶
Constants ¶
View Source
const (
// EncryptedPrefix is prepended to encrypted values to identify them.
EncryptedPrefix = "enc:v1:"
)
Variables ¶
View Source
var ( // ErrInvalidCiphertext indicates the ciphertext is malformed. ErrInvalidCiphertext = errors.New("invalid ciphertext") // ErrNoEncryptionKey indicates no encryption key is available. ErrNoEncryptionKey = errors.New("no encryption key configured") )
Functions ¶
func IsEncrypted ¶
IsEncrypted checks if a value is encrypted (has the encrypted prefix).
Types ¶
type Encryptor ¶
type Encryptor struct {
// contains filtered or unexported fields
}
Encryptor handles encryption and decryption of sensitive data.
func Default ¶
func Default() *Encryptor
Default returns the default Encryptor instance, initializing it if necessary. The encryption key is derived from the ENCRYPTION_KEY environment variable, or falls back to a machine-specific key if not set.
func New ¶
New creates a new Encryptor with the given key. Key must be exactly 32 bytes for AES-256.
Click to show internal directories.
Click to hide internal directories.