core

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(passwd string) error

CheckPassword validate password string

Types

type Box

type Box struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Box represents password box

func NewBox

func NewBox(repo BoxRepository) *Box

NewBox creates box with repo

func (*Box) Add

func (box *Box) Add(pw *Password) (id string, new bool, err error)

Add adds a new password to box

func (*Box) Clear

func (box *Box) Clear() ([]string, error)

Clear clear password box

func (*Box) Find

func (box *Box) Find(w io.Writer, word string, justPassword, justFirst bool) error

Find finds password by word

func (*Box) Init

func (box *Box) Init(masterPassword string) error

Init initialize box with master password

func (*Box) Inspect

func (box *Box) Inspect(w io.Writer, ids []string, all bool) error

Inspect show low-level information of password

func (*Box) List

func (box *Box) List(w io.Writer, noHeader, showHidden bool) error

List writes all passwords to specified writer

func (*Box) Remove

func (box *Box) Remove(ids []string, all bool) ([]string, error)

Remove removes passwords by ids

func (*Box) RemoveByAccount

func (box *Box) RemoveByAccount(category, account string, all bool) ([]string, error)

RemoveByAccount removes passwords by category and account

func (*Box) Update

func (box *Box) Update(newMasterPassword string) error

Update updates master password

func (*Box) Upgrade

func (box *Box) Upgrade() (from, to int, err error)

Upgrade upgrade to current version

type BoxRepository

type BoxRepository interface {
	Load() ([]byte, error)
	Save([]byte) error
}

BoxRepository define repo for storing passwords

func NewFileRepository

func NewFileRepository(filename string) BoxRepository

NewFileRepository creates a FileRepository

func NewMemRepository

func NewMemRepository(data []byte) BoxRepository

type Password

type Password struct {
	PasswordBasic

	// Unique id of password
	ID string `cli:"id" usage:"Password id for updating"`

	// IVs
	AccountIV  []byte `cli:"-"`
	PasswordIV []byte `cli:"-"`

	// Ciphers
	CipherAccount  []byte `cli:"-"`
	CipherPassword []byte `cli:"-"`

	// Created time stamp
	CreatedAt int64 `cli:"-"`

	// Last updated time stamp
	LastUpdatedAt int64 `cli:"-"`
}

Password represents entity of password

func NewEmptyPassword

func NewEmptyPassword() *Password

NewEmptyPassword creates a empty Password entity

func NewPassword

func NewPassword(category, account, passwd, site string) *Password

NewPassword creates a Password entity

func (*Password) ShortID

func (pw *Password) ShortID() string

ShortID returns short length id string

type PasswordBasic

type PasswordBasic struct {
	// Category of password
	Category string `cli:"c,category" usage:"Category of password"`

	// Plain account and password
	PlainAccount  string `json:"-" cli:"u,account" usage:"Account of password"`
	PlainPassword string `json:"-" cli:"-"`

	// Website address for web password
	Site string `cli:"site" usage:"Website of password"`

	// Password tags
	Tags []string `cli:"tag" usage:"Tags of password"`

	// Extension information: JSON base64 string
	Ext string `cli:"-"`

	// Hidden ...
	Hidden bool `cli:"H,hidden" usage:"Whether to hide the password" dft:"false"`
}

PasswordBasic is basic of Password

Jump to

Keyboard shortcuts

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