pg

package
v0.0.0-...-5decaeb Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2017 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NonceSize = aes.BlockSize
	MACSize   = 32 // Output size of HMAC-SHA-256
	CKeySize  = 32 // Cipher key size - AES-256
	MKeySize  = 32 // HMAC key size - HMAC-SHA-256
)

Variables

View Source
var (
	ErrEncrypt = errors.New("secret: encryption failed")
	ErrDecrypt = errors.New("secret: decryption failed")
)
View Source
var KeySize = CKeySize + MKeySize

Functions

func Decrypt

func Decrypt(key, message []byte) ([]byte, error)

func Encrypt

func Encrypt(key, message []byte) ([]byte, error)

func GenRandPassword

func GenRandPassword(len, uCaseLen, lCaseLen, numLen, puncLen int) string

func Key

func Key(key string) []byte

func Path

func Path() (string, error)

Types

type Entry

type Entry struct {
	Domain   string   `json:"domain"`
	Username string   `json:"username"`
	Password Password `json:"password"`
}

type EntryMgr

type EntryMgr struct {
	Entries map[string]map[string]Entry
	// contains filtered or unexported fields
}

func NewEntryMgr

func NewEntryMgr(persistance EntryPersistant) (*EntryMgr, error)

func (*EntryMgr) Flush

func (em *EntryMgr) Flush()

func (*EntryMgr) Get

func (em *EntryMgr) Get(domain string, username string) (entry Entry, ok bool)

func (*EntryMgr) Put

func (em *EntryMgr) Put(entry Entry)

func (*EntryMgr) Remove

func (em *EntryMgr) Remove(domain string, username string) (ok bool)

type EntryPersistant

type EntryPersistant interface {
	Restore() (entries []Entry, err error)
	Save(entries []Entry) error
}

func NewFileEntryPersistant

func NewFileEntryPersistant(path string) EntryPersistant

type FileEntryPersistant

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

func (*FileEntryPersistant) Restore

func (f *FileEntryPersistant) Restore() (entries []Entry, err error)

func (*FileEntryPersistant) Save

func (f *FileEntryPersistant) Save(entries []Entry) error

type Password

type Password string

func NewPassword

func NewPassword(key string, plaintext string) (Password, error)

func (Password) Plaintext

func (p Password) Plaintext(key string) (string, error)

Jump to

Keyboard shortcuts

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