mirror of
https://github.com/FiloSottile/age.git
synced 2026-03-11 08:55:41 +00:00
plugin: add String methods to Recipient and Identity
This commit is contained in:
parent
2a671dca00
commit
d29d7515b6
1 changed files with 14 additions and 0 deletions
|
|
@ -52,6 +52,15 @@ func (r *Recipient) Name() string {
|
|||
return r.name
|
||||
}
|
||||
|
||||
// String returns the recipient encoding string ("age1name1...") or
|
||||
// "<identity-based recipient>" if r was created by [Identity.Recipient].
|
||||
func (r *Recipient) String() string {
|
||||
if r.identity {
|
||||
return "<identity-based recipient>"
|
||||
}
|
||||
return r.encoding
|
||||
}
|
||||
|
||||
func (r *Recipient) Wrap(fileKey []byte) (stanzas []*age.Stanza, err error) {
|
||||
stanzas, _, err = r.WrapWithLabels(fileKey)
|
||||
return
|
||||
|
|
@ -193,6 +202,11 @@ func (i *Identity) Name() string {
|
|||
return i.name
|
||||
}
|
||||
|
||||
// String returns the identity encoding string ("AGE-PLUGIN-NAME-1...").
|
||||
func (i *Identity) String() string {
|
||||
return i.encoding
|
||||
}
|
||||
|
||||
// Recipient returns a Recipient wrapping this identity. When that Recipient is
|
||||
// used to encrypt a file key, the identity encoding is provided as-is to the
|
||||
// plugin, which is expected to support encrypting to identities.
|
||||
|
|
|
|||
Loading…
Reference in a new issue