Documentation
¶
Overview ¶
Package encrypt provides a DI-friendly AES-256-GCM string encryption service.
Index ¶
Constants ¶
View Source
const KeySize = 32
KeySize is the required key length in bytes (AES-256).
Variables ¶
View Source
var ErrInvalidKeySize = errors.New("encrypt: key must be 32 bytes (AES-256)")
ErrInvalidKeySize is returned when EncryptConfig.Key is not exactly KeySize bytes.
Functions ¶
This section is empty.
Types ¶
type EncryptConfig ¶
type EncryptConfig struct {
// Key is the raw AES-256 key; it must be exactly 32 bytes.
Key string
}
EncryptConfig holds AES-256-GCM encryption settings.
type EncryptService ¶
type EncryptService struct {
Key string
}
EncryptService performs AES-256-GCM encrypt/decrypt with an injected key. Ciphertext strings are base64(nonce || ciphertext || tag).
func NewEncryptService ¶
func NewEncryptService(e *EncryptService) *EncryptService
NewEncryptService copies the key from an existing service.
func NewEncryptServiceFromConfig ¶
func NewEncryptServiceFromConfig(cfg EncryptConfig) (*EncryptService, error)
NewEncryptServiceFromConfig constructs a service from config (Wire / tests). It returns ErrInvalidKeySize when the key is not 32 bytes.
Click to show internal directories.
Click to hide internal directories.