Documentation ¶
Index ¶
- Variables
- func RowTagWithPrefix(r *Row, prefixes ...string) string
- func SaveRowAsFile(r *Row, dir string) (filepath string, err error)
- type Row
- func (row *Row) Decrypt(key *[32]byte) error
- func (row *Row) Decrypted() []byte
- func (row *Row) Format() string
- func (row *Row) HasPlainTag(plain string) bool
- func (row *Row) HasRandomTag(randtag string) bool
- func (row *Row) PlainTags() []string
- func (row *Row) Populate(key *[32]byte, pairs TagPairs) error
- func (row *Row) SetPlainTags(pairs TagPairs) error
- type Rows
- type TagPair
- type TagPairs
Constants ¶
This section is empty.
Variables ¶
var (
Debug = false
)
var (
ErrRowsNotFound = errors.New("No rows found")
)
var (
ErrTagPairNotFound = errors.New("TagPair(s) not found")
)
Functions ¶
func RowTagWithPrefix ¶
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 ¶
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 ¶
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 ¶
NewRowFromBytes unmarshals b into a new *Row.
func (*Row) Decrypt ¶
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 ¶
Decrypted returns row.decrypted, row's (unexported) decrypted data (if any).
func (*Row) Format ¶
Format formats row for printing to the terminal. Only suitable for plain text Rows.
func (*Row) HasPlainTag ¶
HasPlainTag answers the question, "does row have the plain tag plain?"
func (*Row) HasRandomTag ¶
HasRandomTag answers the question, "does row have the random tag randtag?"
func (*Row) PlainTags ¶
PlainTags returns row.plaintags, row's (unexported) plain (human-entered, human-readable) tags.
func (*Row) Populate ¶
Populate sets row.decrypted based on row.Encrypted and row.plainTags based on row.RandomTags, thereby populating row with plaintext data.
func (*Row) SetPlainTags ¶
SetPlainTags uses row.RandomTags and pairs to set row.plainTags
type Rows ¶
type Rows []*Row
func (Rows) WithAllRandomTags ¶ added in v0.5.2
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 }