NAME
Crypt::Age::Stanza - Base class for age recipient stanzas
VERSION
version 0.001
SYNOPSIS
use Crypt::Age::Stanza;
# Create a stanza
my $stanza = Crypt::Age::Stanza->new(
type => 'X25519',
args => ['base64-encoded-ephemeral-key'],
body => $wrapped_file_key_bytes,
);
# Serialize to string
my $text = $stanza->to_string;
# -> X25519 base64-encoded-ephemeral-key
# base64-wrapped-file-key
DESCRIPTION
This is the base class for age recipient stanzas.
A stanza represents one way to unwrap the file key. Each recipient in an age file gets their own stanza. The stanza contains the information needed to unwrap the file key if you have the corresponding private identity.
Stanzas have three parts:
type- The recipient type (e.g.,X25519,scrypt)args- Type-specific arguments (e.g., ephemeral public key)body- The wrapped file key (base64-encoded in the file)
The stanza format in an age file is:
-> type arg1 arg2 ...
base64-wrapped-key-line1
base64-wrapped-key-line2
...
Subclasses like Crypt::Age::Stanza::X25519 implement the actual wrapping and unwrapping logic for specific recipient types.
type
The stanza type (e.g., X25519, scrypt).
Required.
args
ArrayRef of type-specific arguments.
For X25519 stanzas, this is the base64-encoded ephemeral public key.
body
The wrapped file key as raw bytes.
This is base64-encoded when serialized to the age file format.
to_string
my $text = $stanza->to_string;
Serializes the stanza to age file format.
Returns a multi-line string with the stanza header (-> type args...) and base64-encoded body wrapped at 64 characters per line.
FUNCTIONS
encode_base64_no_padding
my $encoded = Crypt::Age::Stanza::encode_base64_no_padding($bytes);
Encodes bytes to base64 without padding (no trailing = characters).
This is the encoding used for all base64 in the age format.
decode_base64_no_padding
my $bytes = Crypt::Age::Stanza::decode_base64_no_padding($encoded);
Decodes base64 without padding.
Automatically adds back the padding before decoding.
SEE ALSO
Crypt::Age - Main age encryption module
Crypt::Age::Header - Header parsing and generation
Crypt::Age::Stanza::X25519 - X25519 recipient stanza implementation
SUPPORT
Issues
Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-crypt-age/issues.
IRC
You can reach Getty on irc.perl.org for questions and support.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <torsten@raudssus.de>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.