Convert::BaseN(3pm)
π Convert::BaseN π
okay so bestie, let me put you on to something β¨ this whole page comes to you from the User Contributed Perl Documentation, and it's all about Convert::BaseN π
πΈ NAME πΈ
Convert::BaseN β encoding and decoding of base{2,4,8,16,32,64} strings π¦
π VERSION π
$Id: BaseN.pm,v 0.1 2008/06/16 17:34:27 dankogai Exp dankogai $
(yes it's giving vintage, we still stan π)
β¨ SYNOPSIS β¨
use Convert::BaseN;
# by name
my $cb = Convert::BaseN->new('base64');
my $cb = Convert::BaseN->new( name => 'base64' );
# or base
my $cb = Convert::BaseN->new( base => 64 );
my $cb_url = Convert::BaseN->new(
base => 64,
chars => '0-9A-Za-z\-_='
);
# encode and decode
$encoded = $cb->encode($data);
$decoded = $cb->decode($encoded);
π«Ά EXPORT π«Ά
Nothing. zero, nada, we don't do that here π instead of exporting anything, this module builds a transcoder object for you, and then you hit it with its decode and encode methods to get the job done. it's giving delegation, it's giving main character energy π
π₯ FUNCTIONS π₯
π« new
Create the transcoder object. iconic behaviour, honestly.
# by name
my $cb = Convert::BaseN->new('base64');
my $cb = Convert::BaseN->new( name => 'base64' );
# or base
my $cb = Convert::BaseN->new( base => 64 );
my $cb_url = Convert::BaseN->new(
base => 64,
chars => '0-9A-Za-z\-_='
);
You can pick your decoder by name, or craft your own by specifying the base and the character map. your call, bestie π
baseβ must be2,4,16,32or64. that's it. no base 8 shenanigans, don't try it πcharsβ specifies the character map. the format is the exact same astr. fr fr.
# DNA is coded that way.
my $dna = Convert::BaseN->new( base => 4, chars => 'ACGT' );
padding,nopaddingβ specifies whether padding (adding'='or other chars) is required when encoding. the default is yes π
# url-safe Base64
my $b64url = Convert::BaseN->new(
base => 64, chars => '0-9A-Za-z\-_=', padding => 0;
);
nameβ when you specify this, the following pre-defined encodings get used πbase2β base 2 encoding."perl"is01110000011001010111001001101100.base4,DNA,RNAβ base 4 encodings."perl"is:
base4: 1300121113021230
DNA: CTAACGCCCTAGCGTA
RNA: GAUUGCGGGAUCGCAU
- base 16 encoding.
"perl"is7065726c.
ngl the original page lowkey ghosts the label on this one, but it's base 16 and that's the vibe π
base32,base32hexβ base 32 encoding mentioned in RFC4648."perl"is:
base32: OBSXE3A==
base32hex: E1IN4R0==
base64,base64_url,base64_imap,base64_ircuβ base 64 encoding, as inMIME::Base64. they differ only in the characters used to represent number 62 and 63, like so:
base64: +/
base64_url: -_
base64_imap: +,
base64_ircu: []
and for ALL predefined base 64 variants, decode accepts ANY form of those. so flexible, we love to see it ππ
π§ decode
Does decode. that's the whole job description, she's efficient like that.
my $decoded = $cb->decode($data)
π encode
Does encode. also efficient. also slaying.
# line folds every 76 octets, like MIME::Base64::encode
my $encoded = $cb->encode($data);
# no line folding (compatibile w/ MIME::Base64)
my $encoded = $cb->encode($data, "");
# line folding by CRLF, every 40 octets
my $encoded = $cb->encode($data, "\r\n", 40);
π¦ SEE ALSO π¦
- RFC4648
http://tools.ietf.org/html/rfc4648 - Wikipedia
http://en.wikipedia.org/wiki/Base64 http://www.centricorp.com/papers/base64.htmMIME::Base64MIME::Base32MIME::Base64::URLSafe
π AUTHOR π
Dan Kogai, "<dankogai at dan.co.jp>"
π BUGS π
Please report any bugs or feature requests to "bug-convert-basen at rt.cpan.org", or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Convert-BaseN. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. so you'll literally never be left on read, periodt π
π SUPPORT π
You can find documentation for this module with the perldoc command.
perldoc Convert::BaseN
You can also look for information at:
- RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Convert-BaseN
- AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Convert-BaseN
- CPAN Ratings
http://cpanratings.perl.org/d/Convert-BaseN
- Search CPAN
http://search.cpan.org/dist/Convert-BaseN
π ACKNOWLEDGEMENTS π
N/A
π COPYRIGHT & LICENSE π
Copyright 2008 Dan Kogai, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie π«Ά this little gem shipped as perl v5.36.0 on 2022-10-13 and it's filed under Convert::BaseN(3pm). go forth and encode responsibly β¨πΈπ
π¦ where this page comes from
- ubuntu noble: libconvert-basen-perl 0.01-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libconvert-basen-perl 0.01-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libconvert-basen-perl 0.01-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms