.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Convert::BaseN 3pm" .TH Convert::BaseN 3pm "2022-10-13" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Convert::BaseN \- encoding and decoding of base{2,4,8,16,32,64} strings .SH "VERSION" .IX Header "VERSION" \&\f(CW$Id:\fR BaseN.pm,v 0.1 2008/06/16 17:34:27 dankogai Exp dankogai $ .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 10 \& use Convert::BaseN; \& # by name \& my $cb = Convert::BaseN\->new(\*(Aqbase64\*(Aq); \& my $cb = Convert::BaseN\->new( name => \*(Aqbase64\*(Aq ); \& # or base \& my $cb = Convert::BaseN\->new( base => 64 ); \& my $cb_url = Convert::BaseN\->new( \& base => 64, \& chars => \*(Aq0\-9A\-Za\-z\e\-_=\*(Aq \& ); \& # encode and decode \& $encoded = $cb\->encode($data); \& $decoded = $cb\->decode($encoded); .Ve .SH "EXPORT" .IX Header "EXPORT" Nothing. Instead of that, this module builds \fItranscoder object\fR for you and you use its \f(CW\*(C`decode\*(C'\fR and \f(CW\*(C`encode\*(C'\fR methods to get the job done. .SH "FUNCTIONS" .IX Header "FUNCTIONS" .SS "new" .IX Subsection "new" Create the transcoder object. .PP .Vb 9 \& # by name \& my $cb = Convert::BaseN\->new(\*(Aqbase64\*(Aq); \& my $cb = Convert::BaseN\->new( name => \*(Aqbase64\*(Aq ); \& # or base \& my $cb = Convert::BaseN\->new( base => 64 ); \& my $cb_url = Convert::BaseN\->new( \& base => 64, \& chars => \*(Aq0\-9A\-Za\-z\e\-_=\*(Aq \& ); .Ve .PP You can pick the decoder by name or create your own by specifying base and character map. .IP "base" 2 .IX Item "base" Must be 2, 4, 16, 32 or 64. .IP "chars" 2 .IX Item "chars" Specifiles the character map. The format is the same as \f(CW\*(C`tr\*(C'\fR. .Sp .Vb 2 \& # DNA is coded that way. \& my $dna = Convert::BaseN\->new( base => 4, chars => \*(AqACGT\*(Aq ); .Ve .IP "padding" 2 .IX Item "padding" .PD 0 .IP "nopadding" 2 .IX Item "nopadding" .PD Specifies if padding (adding '=' or other chars) is required when encoding. default is yes. .Sp .Vb 4 \& # url\-safe Base64 \& my $b64url = Convert::BaseN\->new( \& base => 64, chars => \*(Aq0\-9A\-Za\-z\e\-_=\*(Aq, padding => 0; \& ); .Ve .IP "name" 2 .IX Item "name" When specified, the following pre-defined encodings will be used. .RS 2 .IP "base2" 2 .IX Item "base2" base 2 encoding. \f(CW\*(C`perl\*(C'\fR is \f(CW01110000011001010111001001101100\fR. .IP "base4" 2 .IX Item "base4" .PD 0 .IP "\s-1DNA\s0" 2 .IX Item "DNA" .IP "\s-1RNA\s0" 2 .IX Item "RNA" .PD base 4 encodings. \f(CW\*(C`perl\*(C'\fR is: .Sp .Vb 3 \& base4: 1300121113021230 \& DNA: CTAACGCCCTAGCGTA \& RNA: GAUUGCGGGAUCGCAU .Ve .Sp base 16 encoding. \f(CW\*(C`perl\*(C'\fR is \f(CW\*(C`7065726c\*(C'\fR. .IP "base32" 2 .IX Item "base32" .PD 0 .IP "base32hex" 2 .IX Item "base32hex" .PD base 32 encoding mentioned in \s-1RFC4648.\s0 \f(CW\*(C`perl\*(C'\fR is: .Sp .Vb 2 \& base32: OBSXE3A== \& base32hex: E1IN4R0== .Ve .IP "base64" 2 .IX Item "base64" .PD 0 .IP "base64_url" 2 .IX Item "base64_url" .IP "base64_imap" 2 .IX Item "base64_imap" .IP "base64_ircu" 2 .IX Item "base64_ircu" .PD base 64 encoding, as in MIME::Base64. They differ only in characters to represent number 62 and 63 as follows. .Sp .Vb 4 \& base64: +/ \& base64_url: \-_ \& base64_imap: +, \& base64_ircu: [] .Ve .Sp for all predefined base 64 variants, \f(CW\*(C`decode\*(C'\fR accept \s-1ANY\s0 form of those. .RE .RS 2 .RE .SS "decode" .IX Subsection "decode" Does decode .PP .Vb 1 \& my $decoded = $cb\->decode($data) .Ve .SS "encode" .IX Subsection "encode" Does encode. .PP .Vb 6 \& # 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, "\er\en", 40); .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\s-1RFC4648\s0 .PP Wikipedia .PP .PP MIME::Base64 .PP MIME::Base32 .PP MIME::Base64::URLSafe .SH "AUTHOR" .IX Header "AUTHOR" Dan Kogai, \f(CW\*(C`\*(C'\fR .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests to \f(CW\*(C`bug\-convert\-basen at rt.cpan.org\*(C'\fR, or through the web interface at . I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. .SH "SUPPORT" .IX Header "SUPPORT" You can find documentation for this module with the perldoc command. .PP .Vb 1 \& perldoc Convert::BaseN .Ve .PP You can also look for information at: .IP "\(bu" 4 \&\s-1RT: CPAN\s0's request tracker .Sp .IP "\(bu" 4 AnnoCPAN: Annotated \s-1CPAN\s0 documentation .Sp .IP "\(bu" 4 \&\s-1CPAN\s0 Ratings .Sp .IP "\(bu" 4 Search \s-1CPAN\s0 .Sp .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" N/A .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright 2008 Dan Kogai, all rights reserved. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.