vault

package
v0.0.0-...-deba36d Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Key  string
	Type EntryType
	// contains filtered or unexported fields
}

Entry provides name and type information for an entry in a vault

type EntryType

type EntryType int

EntryType represents the type of a given entry in a vault

const (
	// EntryTypeString is for entries of type string
	EntryTypeString EntryType = 0
	// EntryTypeBytes is for entries of type []byte
	EntryTypeBytes EntryType = 1
)

func (EntryType) String

func (e EntryType) String() string

type SCryptStrength

type SCryptStrength int

SCryptStrength represents the N, r, p values for scrypt. Read more: http://www.tarsnap.com/scrypt/scrypt-slides.pdf

const (
	// SCryptInteractive is suitiable for interactive use (<100ms) [N:2^14, r:8, p:1]
	SCryptInteractive SCryptStrength = 0
	// SCryptSensitive is suitiable for sensitive long-term storage (<100ms) [N:2^20, r:8, p:1]
	SCryptSensitive SCryptStrength = 1
)

type Vault

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

Vault is an encrypted store of key/value pairs

func Create

func Create(path string, passphrase string, strength SCryptStrength) (*Vault, []byte, error)

Create creates a new vault at the given destination

func Open

func Open(path string, passphrase string, firstTryKey []byte) (*Vault, []byte, error)

Open decrypts and deserializes a vault from a file

func (*Vault) GetBytes

func (v *Vault) GetBytes(key string) ([]byte, error)

GetBytes returns the []byte value for the given key and a found/not-found indicator

func (*Vault) GetString

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

GetString returns the string value for the given key and a found/not-found indicator

func (*Vault) List

func (v *Vault) List() []*Entry

List returns a list of entries in the vault

func (*Vault) Rekey

func (v *Vault) Rekey(newPassphrase string, strength SCryptStrength) error

func (*Vault) Remove

func (v *Vault) Remove(key string)

Remove removes a given entry

func (*Vault) Save

func (v *Vault) Save() error

func (*Vault) SetBytes

func (v *Vault) SetBytes(key string, value []byte)

SetBytes sets the value of a given key to the given []byte

func (*Vault) SetString

func (v *Vault) SetString(key string, value string)

SetString sets the value of a given key to the given string

Jump to

Keyboard shortcuts

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