Convert::BaseN3pm
Encoding and decoding of base{2,4,8,16,32,64} strings
Usage
use Convert::BaseN;# by namemy $cb = Convert::BaseN->new('base64');my $cb = Convert::BaseN->new( name => 'base64' );# or basemy $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);
Version
$Id: BaseN.pm,v 0.1 2008/06/16 17:34:27 dankogai Exp dankogai $
Export
Nothing. Instead of that, this module builds transcoder object for you and you use its "decode" and "encode" methods to get the job done.
Functions
new
Create the transcoder object.
# by namemy $cb = Convert::BaseN->new('base64');my $cb = Convert::BaseN->new( name => 'base64' );# or basemy $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.
- base
-
Must be 2, 4, 16, 32 or 64.
- chars
-
Specifiles the character map. The format is the same as
"tr".# DNA is coded that way.my $dna = Convert::BaseN->new( base => 4, chars => 'ACGT' );
- padding
- nopadding
-
Specifies if padding (adding '=' or other chars) is required when encoding. default is yes.
# url-safe Base64my $b64url = Convert::BaseN->new(base => 64, chars => '0-9A-Za-z\-_=', padding => 0;);
- name
-
When specified, the following pre-defined encodings will be used.
- base2
-
base 2 encoding.
"perl"is01110000011001010111001001101100.
- base4
- DNA
- RNA
-
base 4 encodings.
"perl"is:base4: 1300121113021230DNA: CTAACGCCCTAGCGTARNA: GAUUGCGGGAUCGCAUbase 16 encoding.
"perl"is"7065726c".
- 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 in MIME::Base64. They differ only in characters to represent number 62 and 63 as follows.
base64: +/base64_url: -_base64_imap: +,base64_ircu: []for all predefined base 64 variants,
"decode"accept ANY form of those.
decode
Does decode
my $decoded = $cb->decode($data)
encode
Does encode.
# line folds every 76 octets, like MIME::Base64::encodemy $encoded = $cb->encode($data);# no line folding (compatibile w/ MIME::Base64)my $encoded = $cb->encode($data, "");# line folding by CRLF, every 40 octetsmy $encoded = $cb->encode($data, "\r\n", 40);
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.
Releases
6 releases since Debian 8 (Jessie); the text changed 2 times.