Documentation
¶
Index ¶
- Constants
- func DecryptWithPassphrase(data []byte, passphrase string) ([]byte, error)
- func EncryptWithPassphrase(plaintext []byte, passphrase string) ([]byte, error)
- func GetDefaultKeyPath() string
- func GetProjectKeyPath(projectDir string) string
- func IsEncrypted(data []byte) bool
- func IsFileEncrypted(filePath string) (bool, error)
- func IsPassphraseEncrypted(data []byte) bool
- type EncryptedData
- type Encryptor
- func (e *Encryptor) Decrypt(data []byte) ([]byte, error)
- func (e *Encryptor) DecryptFile(filePath string) error
- func (e *Encryptor) DecryptString(encrypted string) (string, error)
- func (e *Encryptor) Encrypt(plaintext []byte) ([]byte, error)
- func (e *Encryptor) EncryptFile(filePath string) error
- func (e *Encryptor) EncryptString(plaintext string) (string, error)
- func (e *Encryptor) ReadEncryptedFile(filePath string) ([]byte, error)
- func (e *Encryptor) WriteEncryptedFile(filePath string, data []byte, perm os.FileMode) error
- type PassphraseEncryptedData
Constants ¶
const (
// EncryptionHeader marks encrypted files
EncryptionHeader = "TAKO_ENCRYPTED_V1:"
)
const (
// PassphraseHeader marks passphrase-encrypted data
PassphraseHeader = "TAKO_PASSPHRASE_V1:"
)
Variables ¶
This section is empty.
Functions ¶
func DecryptWithPassphrase ¶ added in v0.2.6
DecryptWithPassphrase decrypts data that was encrypted with EncryptWithPassphrase
func EncryptWithPassphrase ¶ added in v0.2.6
EncryptWithPassphrase encrypts plaintext using a passphrase with Argon2id KDF + AES-256-GCM
func GetDefaultKeyPath ¶
func GetDefaultKeyPath() string
GetDefaultKeyPath returns the default encryption key path
func GetProjectKeyPath ¶
GetProjectKeyPath returns the project-specific encryption key path
func IsEncrypted ¶
IsEncrypted checks if data has the encryption header
func IsFileEncrypted ¶
IsFileEncrypted checks if a file is encrypted
func IsPassphraseEncrypted ¶ added in v0.2.6
IsPassphraseEncrypted checks if data has the passphrase encryption header
Types ¶
type EncryptedData ¶
type EncryptedData struct {
Salt string `json:"salt"` // Base64 encoded salt
Nonce string `json:"nonce"` // Base64 encoded nonce
Ciphertext string `json:"ciphertext"` // Base64 encoded encrypted data
}
EncryptedData represents the structure of encrypted content
type Encryptor ¶
type Encryptor struct {
// contains filtered or unexported fields
}
Encryptor handles encryption/decryption operations
func NewEncryptor ¶
NewEncryptor creates a new Encryptor with the given passphrase The passphrase is derived into a secure key using PBKDF2
func NewEncryptorFromKeyFile ¶
NewEncryptorFromKeyFile creates an Encryptor using a key file If the key file doesn't exist, it generates a new random key
func (*Encryptor) DecryptFile ¶
DecryptFile decrypts a file in place
func (*Encryptor) DecryptString ¶
DecryptString decrypts a string that was encrypted with EncryptString
func (*Encryptor) EncryptFile ¶
EncryptFile encrypts a file in place
func (*Encryptor) EncryptString ¶
EncryptString encrypts a string and returns base64-encoded result
func (*Encryptor) ReadEncryptedFile ¶
ReadEncryptedFile reads and decrypts a file, returning plaintext If file is not encrypted, returns contents as-is
type PassphraseEncryptedData ¶ added in v0.2.6
type PassphraseEncryptedData struct {
Salt string `json:"salt"` // Base64 encoded salt
Nonce string `json:"nonce"` // Base64 encoded nonce
Ciphertext string `json:"ciphertext"` // Base64 encoded encrypted data
Time uint32 `json:"time"` // Argon2id time parameter
Memory uint32 `json:"memory"` // Argon2id memory parameter (KiB)
Threads uint8 `json:"threads"` // Argon2id threads parameter
}
PassphraseEncryptedData represents passphrase-encrypted content