1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
|
NAME
Convert::BaseN - encoding and decoding of base{2,4,8,16,32,64} strings
VERSION
$Id: README,v 0.1 2008/06/16 17:34:27 dankogai Exp dankogai $
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. 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 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.
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 Base64
my $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" is 01110000011001010111001001101100.
base4
DNA
RNA
base 4 encodings. "perl" is:
base4: 1300121113021230
DNA: CTAACGCCCTAGCGTA
RNA: GAUUGCGGGAUCGCAU
base 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::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.htm>
MIME::Base64
MIME::Base32
MIME::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.
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.
|