Documentation
¶
Index ¶
Constants ¶
const ( // ExportVersion is the current export format version ExportVersion = "1" // Algorithm specifies the encryption algorithm used Algorithm = "aes-256-gcm" // SaltLength is the length of the salt in bytes SaltLength = 16 // KeyLength is the length of the derived key in bytes (256 bits) KeyLength = 32 // PBKDF2Iterations is the number of iterations for PBKDF2 PBKDF2Iterations = 100000 // MinPasswordLength is the minimum required password length MinPasswordLength = 8 )
const EncryptedPrefix = "ENC:"
EncryptedPrefix is the prefix used to identify encrypted values
Variables ¶
This section is empty.
Functions ¶
func ExportVersionVersion ¶
func ExportVersionVersion() string
ExportVersionVersion returns the current export version
func GetOrCreateKeyFile ¶
GetOrCreateKeyFile gets or creates a key file for additional security (optional)
func IsEncrypted ¶
IsEncrypted checks if a string appears to be encrypted Uses the ENC: prefix for reliable detection
func ValidatePassword ¶
ValidatePassword validates that the password meets security requirements
Types ¶
type EncryptedExport ¶
type EncryptedExport struct {
Version string `json:"version"`
Algorithm string `json:"algorithm"`
Salt string `json:"salt"`
Nonce string `json:"nonce"`
Data string `json:"data"`
}
EncryptedExport represents the encrypted export format
type ExportConfig ¶
type ExportConfig struct {
Alias string `json:"alias"`
Provider string `json:"provider"`
APIKey string `json:"api_key"`
AuthToken string `json:"auth_token"`
BaseURL string `json:"base_url"`
Model string `json:"model"`
Models []string `json:"models,omitempty"`
}
ExportConfig represents a single exported configuration
func NewExportConfig ¶
func NewExportConfig(alias, provider, apiKey, authToken, baseURL, model string, models []string) ExportConfig
NewExportConfig creates a new ExportConfig from API config values
type ExportFormat ¶
type ExportFormat struct {
Version string `json:"version"`
Timestamp int64 `json:"timestamp"`
Configs []ExportConfig `json:"configs"`
}
ExportFormat represents the unencrypted export format
func NewExportFormat ¶
func NewExportFormat(configs []ExportConfig) *ExportFormat
NewExportFormat creates a new ExportFormat from configurations
type KeyManager ¶
type KeyManager struct {
// contains filtered or unexported fields
}
KeyManager handles encryption and decryption of API keys
func NewKeyManager ¶
func NewKeyManager() (*KeyManager, error)
NewKeyManager creates a new KeyManager with a derived key
type PasswordManager ¶
type PasswordManager struct {
// contains filtered or unexported fields
}
PasswordManager handles password-based encryption and decryption
func NewPasswordManager ¶
func NewPasswordManager(password string) *PasswordManager
NewPasswordManager creates a new PasswordManager with the given password
func (*PasswordManager) Decrypt ¶
func (pm *PasswordManager) Decrypt(encoded string) (*ExportFormat, error)
Decrypt decrypts a base64-encoded encrypted string and returns an ExportFormat
func (*PasswordManager) Encrypt ¶
func (pm *PasswordManager) Encrypt(export *ExportFormat) (string, error)
Encrypt encrypts an ExportFormat and returns a base64-encoded encrypted string