Convert::BaseN(3pm) | User Contributed Perl Documentation | Convert::BaseN(3pm) |
Convert::BaseN - encoding and decoding of base{2,4,8,16,32,64} strings
$Id: BaseN.pm,v 0.1 2008/06/16 17:34:27 dankogai Exp dankogai $
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);
Nothing. Instead of that, this module builds transcoder object for you and you use its "decode" and "encode" methods to get the job done.
Create the transcoder object.
# 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 the decoder by name or create your own by specifying base and character map.
# DNA is coded that way. my $dna = Convert::BaseN->new( base => 4, chars => 'ACGT' );
# url-safe Base64 my $b64url = Convert::BaseN->new( base => 64, chars => '0-9A-Za-z\-_=', padding => 0; );
base4: 1300121113021230 DNA: CTAACGCCCTAGCGTA RNA: GAUUGCGGGAUCGCAU
base 16 encoding. "perl" is "7065726c".
base32: OBSXE3A== base32hex: E1IN4R0==
base64: +/ base64_url: -_ base64_imap: +, base64_ircu: []
for all predefined base 64 variants, "decode" accept ANY form of those.
Does decode
my $decoded = $cb->decode($data)
Does encode.
# 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);
RFC4648 <http://tools.ietf.org/html/rfc4648>
Wikipedia <http://en.wikipedia.org/wiki/Base64>
<http://www.centricorp.com/papers/base64.htm>
MIME::Base64
MIME::Base32
MIME::Base64::URLSafe
Dan Kogai, "<dankogai at dan.co.jp>"
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.
You can find documentation for this module with the perldoc command.
perldoc Convert::BaseN
You can also look for information at:
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Convert-BaseN>
<http://annocpan.org/dist/Convert-BaseN>
<http://cpanratings.perl.org/d/Convert-BaseN>
<http://search.cpan.org/dist/Convert-BaseN>
N/A
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.
2022-10-13 | perl v5.34.0 |