Conver...Armour(3pm)

πŸ“¦
version 1.4 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Convert::ASCII::Armour β€” the manual page, but make it cute πŸ’–

okay so bestie, welcome to Convert::ASCII::Armour(3pm) ✨ it lives in the User Contributed Perl Documentation corner of your system, and it is literally the glow-up your binary data has been waiting for πŸ’…


✨ NAME ✨

Convert::ASCII::Armour β€” turns binary octets into ASCII armoured messages. it's giving "my data went to the spa and came back wearing a little dress" πŸŽ€


🌸 SYNOPSIS 🌸

my $converter = new Convert::ASCII::Armour;

my $message   = $converter->armour(
                    Object   => "FOO RECORD",
                    Headers  => {
                                  Table   => "FooBar",
                                  Version => "1.23",
                                },
                    Content  => {
                                  Key  => "0x8738FA7382",
                                  Name => "Zoya Hall",
                                  Pic  => "....",  # gif
                                },
                    Compress => 1,
                );

print $message;

and like, this is what comes out the other side, no cap:

-----BEGIN COMPRESSED FOO RECORD-----
Version: 1.23
Table: FooBar

eJwzZzA0Z/BNLS5OTE8NycgsVgCiRIVciIAJg6EJg0tiSaqhsYJvYlFy...
XnpOZl5qYlJySmpaekZmVnZObl5+QWFRcUlpWXlFZRWXAk7g6OTs4urm...
Fh4VGaWAR5ehkbGJqZm5hSUeNXWKDsoGcWpaGpq68bba0dWxtTVmDOYM...
NzuZ
=MxpZvjkrv5XyhkVCuXmsBQ==
-----END COMPRESSED FOO RECORD-----

and then the reverse, bestie, the ✨undo✨ button:

my $decoded   = $converter->unarmour( $message )
                 || die $converter->errstr();

πŸ¦‹ DESCRIPTION πŸ¦‹

so this module takes hashes of binary octets and turns them into ASCII messages that are safe to send over 6-bit clean transport channels πŸ‘‘ because sometimes your channel is picky and cannot handle raw bytes, and honestly? mood.

the encoded ASCII resembles PGP's armoured messages, but β€” and this is the important part, don't let anyone tell you otherwise β€” it is in no way compatible with PGP 🚫 lowkey important. like, they're cousins at the family reunion, not twins.


πŸ’œ METHODS πŸ’œ

🌟 new()

Constructor. it makes the thing. that's the whole vibe. ✨

🌟 armour()

converts a hash of binary octets into an ASCII encoded message πŸŽ€

the encoded message has 4 parts, and we're listing all of them because every part is a main character:

  1. head and tail strings that act as identifiers and delimiters
  2. a cluster of headers at the top of the message
  3. the Base64 encoded message body
  4. a Base64 encoded MD5 digest of the message body

armour() takes a hash as its argument, with these keys:

  • Object β€” an identification string that gets embedded in the head and tail strings. it's the little name tag 🏷️
  • Content β€” a hashref holding the binary octets you want encoded. this hash gets serialized, compressed (if you asked for it), and encoded into ASCII with MIME::Base64. the result becomes the body of the encoded message πŸ’…
  • Headers β€” a hashref holding the ASCII headers that get placed at the top of the encoded message. these are encoded as RFC822 headers πŸ“¬
  • Compress β€” a boolean that forces armour() to compress the message body. squeeze it, bestie 🫢

🌟 unarmour()

decodes an armoured ASCII message back into the hash that you'd have handed to armour() πŸ™ˆ the hash contains Content, Object, and Headers.

unarmour() runs several consistency checks, and it returns a non-true value on failure β€” so yeah, check it, don't just assume it ate 😭

🌟 errstr()

returns the error message that unarmour() set when it failed. your little diagnostic bestie when things go sideways πŸ’€


πŸ‘‘ AUTHOR πŸ‘‘

Vipul Ved Prakash, <mail@vipul.net>


πŸŽ€ LICENSE πŸŽ€

Copyright (c) 2001, Vipul Ved Prakash. All rights reserved. This code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


🌈 SEE ALSO 🌈


okay that's the whole page, you ate it, periodt πŸ’– this little legend is from perl v5.36.0, dated 2022-12-04, and it's filed under Conver...Armour(3pm) β€” go forth and armour responsibly, bestie 🧚✨

πŸ“¦ where this page comes from