From d29d7515b6e470c19263e364b1eb014c1835d652 Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Sun, 7 Dec 2025 19:57:28 +0100 Subject: [PATCH] plugin: add String methods to Recipient and Identity --- plugin/client.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/plugin/client.go b/plugin/client.go index 6e19016..28ccbf1 100644 --- a/plugin/client.go +++ b/plugin/client.go @@ -52,6 +52,15 @@ func (r *Recipient) Name() string { return r.name } +// String returns the recipient encoding string ("age1name1...") or +// "" if r was created by [Identity.Recipient]. +func (r *Recipient) String() string { + if r.identity { + return "" + } + 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.