api

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsecurePassphrase = fmt.Errorf("the passphrase does not meet the security requirements")
)

Functions

This section is empty.

Types

type API

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

API is the struct that represents the command line interface of MyKeys. Ir has the filepath of the passwords file, the passphrase to encrypt and decrypt it and a password map.

func New

func New(passphrase string) (*API, error)

New returns an empty API with the given passphrase. It also inits the passwords map. It converts the passphrase from string to a slice of bytes.

func (*API) Del

func (api *API) Del(id string)

Del deletes the password with the given id, if it exists.

func (*API) Export

func (api *API) Export() (string, error)

Export encrypts with the CLI passphrase, and exports the passwords map to a base64url encoded string. It returns an error if the passwords encryption or the base64 encoding fails.

func (*API) Get

func (api *API) Get(id string, json bool) string

Get returns the password with the given alias. If json is true, it will print the json representation of the password. If json is false, it will print the string representation of the password.

func (*API) Import

func (api *API) Import(dump string) error

Import imports the passwords from the base64url encoded string and passphrase provided. It returns an error if the base64url decoding, the passwords decryption or the passwords import fails.

func (*API) List

func (api *API) List(json bool) string

List lists all the passwords in the passwords map. If json is true, it will print the json representation of the passwords map. If json is false, it will print the string representation of the passwords map.

func (*API) Set

func (api *API) Set(alias, username, password string)

Set sets the password with the given alias, username and password. If it already exists, it will be overwritten.

Jump to

Keyboard shortcuts

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