types

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2016 License: AGPL-3.0-or-later Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Debug = false
)
View Source
var (
	ErrRowsNotFound = errors.New("No rows found")
)
View Source
var (
	ErrTagPairNotFound = errors.New("TagPair(s) not found")
)

Functions

func RowTagWithPrefix

func RowTagWithPrefix(r *Row, prefixes ...string) string

RowTagWithPrefix iterates over r's plaintags to grab the data stored in said tags, preferring the prefixes in the order they are passed in.

Example use: RowTagWithPrefix(r, "filename:", "id:"), which will try to return r's filename, then try to return its ID, and if both fail will return empty string.

func SaveRowAsFile

func SaveRowAsFile(r *Row, dir string) (filepath string, err error)

SaveRowAsFile saves the given *Row r to the given directory dir, introspecting r to determine a reasonable filename (either the filename if r contains a file, or r's unique ID). If dir is empty, r is stored in the "decrypted" directory within cryptag.TrustedBasePath ($HOME/.cryptag by default).

Types

type Row

type Row struct {
	// Populated by server
	Encrypted  []byte   `json:"data"`
	RandomTags []string `json:"tags"`

	Nonce *[24]byte `json:"nonce"`
	// contains filtered or unexported fields
}

func NewRow

func NewRow(decrypted []byte, plainTags []string) (*Row, error)

NewRow returns a *Row containing the passed-in values in addition to a unique ID tag ("id:new-uuid-goes-here"), the "all" tag, and a new cryptographic nonce.

func NewRowFromBytes

func NewRowFromBytes(b []byte) (*Row, error)

NewRowFromBytes unmarshals b into a new *Row.

func (*Row) Decrypt

func (row *Row) Decrypt(key *[32]byte) error

Decrypt sets row.decrypted, row.nonce based upon row.Encrypted, nonce. The passed-in `decrypt` function will typically be bkend.Decrypt, where `bkend` is the backend storing this Row.

func (*Row) Decrypted

func (row *Row) Decrypted() []byte

Decrypted returns row.decrypted, row's (unexported) decrypted data (if any).

func (*Row) Format

func (row *Row) Format() string

Format formats row for printing to the terminal. Only suitable for plain text Rows.

func (*Row) HasPlainTag

func (row *Row) HasPlainTag(plain string) bool

HasPlainTag answers the question, "does row have the plain tag plain?"

func (*Row) HasRandomTag

func (row *Row) HasRandomTag(randtag string) bool

HasRandomTag answers the question, "does row have the random tag randtag?"

func (*Row) PlainTags

func (row *Row) PlainTags() []string

PlainTags returns row.plaintags, row's (unexported) plain (human-entered, human-readable) tags.

func (*Row) Populate

func (row *Row) Populate(key *[32]byte, pairs TagPairs) error

Populate sets row.decrypted based on row.Encrypted and row.plainTags based on row.RandomTags, thereby populating row with plaintext data.

func (*Row) SetPlainTags

func (row *Row) SetPlainTags(pairs TagPairs) error

SetPlainTags uses row.RandomTags and pairs to set row.plainTags

type Rows

type Rows []*Row

func (Rows) Format

func (rows Rows) Format() string

func (Rows) Populate

func (rows Rows) Populate(key *[32]byte, pairs TagPairs) error

func (Rows) Sort added in v0.6.3

func (rows Rows) Sort(less func(r1, r2 *Row) bool)

func (Rows) String

func (rows Rows) String() string

func (Rows) WithAllRandomTags added in v0.5.2

func (rows Rows) WithAllRandomTags(random []string) Rows

WithAllRandomTags returns the Rows within rows that has all the random strings in random

type TagPair

type TagPair struct {
	PlainEncrypted []byte    `json:"plain_encrypted"`
	Random         string    `json:"random"`
	Nonce          *[24]byte `json:"nonce"`
	// contains filtered or unexported fields
}

func NewTagPair

func NewTagPair(plainEnc []byte, random string, nonce *[24]byte, plaintag string) *TagPair

func (*TagPair) Decrypt

func (pair *TagPair) Decrypt(key *[32]byte) error

Decrypt sets pair.plain based off of pair.PlainEncrypted

func (*TagPair) Plain

func (pair *TagPair) Plain() string

type TagPairs

type TagPairs []*TagPair

func (TagPairs) AllPlain

func (pairs TagPairs) AllPlain() []string

func (TagPairs) AllRandom

func (pairs TagPairs) AllRandom() []string

func (TagPairs) String

func (pairs TagPairs) String() string

func (TagPairs) WithAllPlainTags added in v0.5.2

func (pairs TagPairs) WithAllPlainTags(plaintags []string) (TagPairs, error)

func (TagPairs) WithAllRandomTags added in v0.5.2

func (pairs TagPairs) WithAllRandomTags(randomtags []string) (TagPairs, error)

Jump to

Keyboard shortcuts

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