vault

package
v0.21.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidFormat = errors.New("invalid vault file format")
	ErrInvalidAuth   = errors.New("authentication failed: wrong password or corrupted data")
)
View Source
var (
	ErrVaultNotFound = errors.New("vault file not found")
	ErrKeyNotFound   = errors.New("key not found in vault")
)
View Source
var ErrWeakPassword = errors.New("password must be at least 8 characters and contain uppercase, lowercase, and digit")

ErrWeakPassword is returned when a password does not meet strength requirements.

Functions

func ValidatePassword

func ValidatePassword(password string) error

ValidatePassword checks that a password meets minimum strength requirements.

Types

type Vault

type Vault struct {
	// contains filtered or unexported fields
}

Vault represents an encrypted vault

func Create

func Create(path string, password string) (*Vault, error)

Create creates a new vault file. Returns an error if the file already exists or the password does not meet strength requirements.

func Open

func Open(path string, password string) (*Vault, error)

Open opens an existing vault. Returns ErrVaultNotFound if the file does not exist.

func TryOpen

func TryOpen(path string, password string) (*Vault, bool, error)

TryOpen opens a vault, returning (vault, true, nil) on success or (nil, false, nil) on auth failure. Other errors (missing file, permission denied, etc.) are returned as (nil, false, err).

func (*Vault) ChangePassword

func (v *Vault) ChangePassword(newPassword string) error

ChangePassword changes the vault password and re-encrypts with new password. Returns an error if the new password does not meet strength requirements.

func (*Vault) Close

func (v *Vault) Close() error

Close saves and closes the vault

func (*Vault) KeyDelete

func (v *Vault) KeyDelete(key string) error

KeyDelete removes a key from the vault

func (*Vault) KeyExists

func (v *Vault) KeyExists(key string) bool

KeyExists checks if a key exists

func (*Vault) KeyGet

func (v *Vault) KeyGet(key string) (string, error)

KeyGet retrieves a value from the vault

func (*Vault) KeyList

func (v *Vault) KeyList() []string

KeyList returns all keys in the vault

func (*Vault) KeySet

func (v *Vault) KeySet(key, value string) error

KeySet stores a value in the vault

func (*Vault) Save

func (v *Vault) Save() error

Save writes the vault to disk

type VaultParams

type VaultParams struct {
	TimeCost    uint32
	MemoryCost  uint32
	Parallelism uint32
}

VaultParams represents Argon2 parameters

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL