passwords

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package passwords contains the in memory data manipulations for password repo

Index

Constants

View Source
const CSVSeparator = ","

CSVSeparator represents the separator for CSV file.

Variables

View Source
var (
	// ErrInvalidID represents the invalid ID error.
	ErrInvalidID = func(id string) error {
		return errors.New(fmt.Sprintf("Invalid ID:  %s", id))
	}
	// ErrCannotSavePasswordDB represents the error when it is unable to save password entry.
	ErrCannotSavePasswordDB = func(err error) error {
		return errors.Wrap(err, "cannot save password")
	}
	// ErrNoPasswords represents the error when no passwords are available.
	ErrNoPasswords = errors.New("no passwords are available")
	// ErrCannotFindMatchForID represents the error when it is unable to find a password entry for the given ID.
	ErrCannotFindMatchForID = func(id string) error {
		return errors.New(fmt.Sprintf("cannot find any match for id %s", id))
	}
)

Functions

func InitRepo added in v0.7.0

func InitRepo(mPassword string) error

InitRepo initialize the Password repository.

Types

type DB added in v0.7.0

type DB struct {
	Entries map[string]Entry    `json:"entries"`
	Labels  map[string][]string `json:"labels"`
}

DB struct represents password db

type Entry added in v0.7.0

type Entry struct {
	ID       string `json:"id"`
	Username string `json:"username"`
	Password string `json:"password"`
}

Entry struct represents entry in the password db

type Repository added in v0.7.0

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

Repository struct handles Password db

func LoadRepo added in v0.7.0

func LoadRepo(mPassword, encryptorID, passwordDBFilePath string) (*Repository, error)

LoadRepo initializes the Password repository.

func (*Repository) Add added in v0.7.0

func (p *Repository) Add(id, uN, password string, labels []string) error

Add method add new password entry to Password db

func (*Repository) ChangeMasterPassword added in v0.7.0

func (p *Repository) ChangeMasterPassword(newPassword string) error

ChangeMasterPassword changes the master password.

func (*Repository) ChangePasswordEntry added in v0.7.0

func (p *Repository) ChangePasswordEntry(id string, entry Entry) error

ChangePasswordEntry changes the password entry.

func (*Repository) ExportToCSV added in v0.7.0

func (p *Repository) ExportToCSV(csvFilePath string) error

ExportToCSV exports the password database to the given CSV file.

func (*Repository) GetPasswordEntry added in v0.7.0

func (p *Repository) GetPasswordEntry(id string) (Entry, error)

GetPasswordEntry gets the password entry from password db.

func (*Repository) GetUsernamePassword added in v0.7.0

func (p *Repository) GetUsernamePassword(id string, showPassword bool) error

GetUsernamePassword method retrieves username and password from Password db.

func (*Repository) ImportFromCSV added in v0.7.0

func (p *Repository) ImportFromCSV(csvFilePath string) error

ImportFromCSV imports the passwords entries from the given CSV file.

func (*Repository) Remove added in v0.7.0

func (p *Repository) Remove(id string) error

Remove removes the password entry of the given id.

func (*Repository) SearchID added in v0.7.0

func (p *Repository) SearchID(id string, showPassword bool) ([]string, error)

SearchID will return the password entries if the password ID contains the provide key.

func (*Repository) SearchLabel added in v0.7.0

func (p *Repository) SearchLabel(label string, showPassword bool) ([]string, error)

SearchLabel will return the password ids if the password labels contains the provide label.

Jump to

Keyboard shortcuts

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