Convert-Ascii85-0.01/0000755000175000001440000000000011535525357013311 5ustar maukeusersConvert-Ascii85-0.01/lib/0000755000175000001440000000000011535525357014057 5ustar maukeusersConvert-Ascii85-0.01/lib/Convert/0000755000175000001440000000000011535525357015477 5ustar maukeusersConvert-Ascii85-0.01/lib/Convert/Ascii85.pm0000644000175000001440000001043011535523204017225 0ustar maukeuserspackage Convert::Ascii85; use warnings; use strict; our $VERSION = '0.01'; use Exporter qw(import); our @EXPORT_OK = qw(ascii85_encode ascii85_decode); my $_space_no = unpack 'N', ' ' x 4; sub encode { my ($in, $opt) = @_; my $compress_zero = exists $opt->{compress_zero} ? $opt->{compress_zero} : 1; my $compress_space = $opt->{compress_space}; my $padding = -length($in) % 4; $in .= "\0" x $padding; my $out = ''; for my $n (unpack 'N*', $in) { if ($n == 0 && $compress_zero) { $out .= 'z'; next; } if ($n == $_space_no && $compress_space) { $out .= 'y'; next; } my $tmp = ''; for my $i (reverse 0 .. 4) { my $mod = $n % 85; $n = int($n / 85); vec($tmp, $i, 8) = $mod + 33; } $out .= $tmp; } $padding or return $out; $out =~ s/z\z/!!!!!/; substr $out, 0, length($out) - $padding } *ascii85_encode = \&encode; sub decode { my ($in) = @_; for ($in) { tr[ \t\r\n\f][]d; s/z/!!!!!/g; s/y/+ (also known as I) algorithm for encoding binary data as text. This is done by interpreting each group of four bytes as a 32-bit integer, which is then converted to a five-digit base-85 representation using the digits from ASCII 33 (C) to 117 (C). This is similar to L but more space efficient: The overhead is only 1/4 of the original data (as opposed to 1/3 for Base64). =head1 FUNCTIONS =over 4 =item Convert::Ascii85::encode DATA =item Convert::Ascii85::encode DATA, OPTIONS Converts the bytes in DATA to Ascii85 and returns the resulting text string. OPTIONS is a hash reference in which the following keys may be set: =over =item compress_zero => 0 By default, four-byte chunks of null bytes (C<"\0\0\0\0">) are converted to C<'z'> instead of C<'!!!!!'>. This can be avoided by passing a false value for C in OPTIONS. =item compress_space => 1 By default, four-byte chunks of spaces (C<' '>) are converted to C<'+. If you pass a true value for C in OPTIONS, they will be converted to C<'y'> instead. =back This function may be exported as C into the caller's namespace. =item Convert::Ascii85::decode TEXT Converts the Ascii85-encoded TEXT back to bytes and returns the resulting byte string. Spaces and linebreaks in TEXT are ignored. This function may be exported as C into the caller's namespace. =back =head1 SEE ALSO L, L =head1 AUTHOR Lukas Mai, C<< >> =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc Convert::Ascii85 You can also look for information at: =over 4 =item * RT: CPAN's request tracker L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * Search CPAN L =back =head1 LICENSE AND COPYRIGHT Copyright 2011 Lukas Mai. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. Convert-Ascii85-0.01/META.yml0000644000175000001440000000115211535525357014561 0ustar maukeusers--- #YAML:1.0 name: Convert-Ascii85 version: 0.01 abstract: Encoding and decoding of ascii85/base85 strings author: - Lukas Mai license: perl distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: Exporter: 5.57 strict: 0 Test::More: 0 warnings: 0 no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.56 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 Convert-Ascii85-0.01/Makefile.PL0000644000175000001440000000122511535522726015260 0ustar maukeusersuse strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Convert::Ascii85', AUTHOR => q{Lukas Mai }, VERSION_FROM => 'lib/Convert/Ascii85.pm', ABSTRACT_FROM => 'lib/Convert/Ascii85.pm', ($ExtUtils::MakeMaker::VERSION >= 6.3002 ? ('LICENSE'=> 'perl') : ()), PL_FILES => {}, PREREQ_PM => { 'Test::More' => 0, 'warnings' => 0, 'strict' => 0, 'Exporter' => '5.57', }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'Convert-Ascii85-*' }, ); Convert-Ascii85-0.01/t/0000755000175000001440000000000011535525357013554 5ustar maukeusersConvert-Ascii85-0.01/t/pod-coverage.t0000644000175000001440000000112711535524123016303 0ustar maukeusersuse strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod::Coverage my $min_tpc = 1.08; eval "use Test::Pod::Coverage $min_tpc"; plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage" if $@; # Test::Pod::Coverage doesn't require a minimum Pod::Coverage version, # but older versions don't recognize some common documentation styles my $min_pc = 0.18; eval "use Pod::Coverage $min_pc"; plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage" if $@; all_pod_coverage_ok({also_private => [qr/^ascii85_(?:de|en)code\z/]}); Convert-Ascii85-0.01/t/interface.t0000644000175000001440000000123511535511003015661 0ustar maukeusers#!perl use warnings; use strict; use Test::More tests => 19; require_ok('Convert::Ascii85'); ok defined &Convert::Ascii85::encode; ok defined &Convert::Ascii85::decode; ok !defined &encode; ok !defined &decode; ok !defined &ascii85_encode; ok !defined &ascii85_decode; use_ok('Convert::Ascii85'); ok !defined &encode; ok !defined &decode; ok !defined &ascii85_encode; ok !defined &ascii85_decode; use_ok('Convert::Ascii85', qw(ascii85_encode ascii85_decode)); ok !defined &encode; ok !defined &decode; ok defined &ascii85_encode; ok defined &ascii85_decode; ok \&ascii85_encode == \&Convert::Ascii85::encode; ok \&ascii85_decode == \&Convert::Ascii85::decode; Convert-Ascii85-0.01/t/basics.t0000644000175000001440000000232711535511027015176 0ustar maukeusers#!perl use warnings; use strict; use Test::More tests => 22; use Convert::Ascii85 qw(ascii85_encode ascii85_decode); my @pairs = ( ['Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.', q~9jqo^BlbD-BleB1DJ+*+F(f,q/0JhKFCj@.4Gp$d7F!,L7@<6@)/0JDEF@3BB/F*&OCAfu2/AKYi(DIb:@FD,*)+C]U=@3BN#EcYf8ATD3s@q?d$AftVqCh[NqF-FD5W8ARlolDIal(DIduD.RTpAKYo'+CT/5+Cei#DII?(E,9)oF*2M7/c~], ["\0" x 8, 'zz'], ["\0" x 8, 'zz', {compress_zero => 1}], ["\0" x 8, '!' x 10, {compress_zero => 0}], ['asdf rew', '@<5sk+ 0}], ['asdf rew', '@<5skyEb0F', {compress_space => 1}], ['', ''], ["\0", '!!'], ["\0\0", '!!!'], ["\0\0\0", '!!!!'], ); for my $pair (@pairs) { my ($plain, $encoded, $options) = @$pair; is ascii85_encode($plain, $options || {}), $encoded; is ascii85_decode($encoded), $plain; } Convert-Ascii85-0.01/t/00-load.t0000644000175000001440000000026711535410573015073 0ustar maukeusers#!perl -T use Test::More tests => 1; BEGIN { use_ok( 'Convert::Ascii85' ) || print "Bail out! "; } diag( "Testing Convert::Ascii85 $Convert::Ascii85::VERSION, Perl $], $^X" ); Convert-Ascii85-0.01/t/pod.t0000644000175000001440000000035011535410573014512 0ustar maukeusers#!perl -T use strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod my $min_tp = 1.22; eval "use Test::Pod $min_tp"; plan skip_all => "Test::Pod $min_tp required for testing POD" if $@; all_pod_files_ok(); Convert-Ascii85-0.01/MANIFEST0000644000175000001440000000031011535525357014434 0ustar maukeusersChanges MANIFEST Makefile.PL README lib/Convert/Ascii85.pm t/00-load.t t/basics.t t/interface.t t/pod-coverage.t t/pod.t META.yml Module meta-data (added by MakeMaker) Convert-Ascii85-0.01/Changes0000644000175000001440000000016411535525225014577 0ustar maukeusersRevision history for Convert-Ascii85 0.01 2011-03-08 First version, released on an unsuspecting world. Convert-Ascii85-0.01/README0000644000175000001440000000214511535520146014162 0ustar maukeusersConvert-Ascii85 This module implements the Ascii85 (also known as Base85) algorithm for encoding binary data as text. This is similar to MIME::Base64 but more space efficient. INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install SUPPORT AND DOCUMENTATION After installing, you can find documentation for this module with the perldoc command. perldoc Convert::Ascii85 You can also look for information at: RT, CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=Convert-Ascii85 AnnoCPAN, Annotated CPAN documentation http://annocpan.org/dist/Convert-Ascii85 CPAN Ratings http://cpanratings.perl.org/d/Convert-Ascii85 Search CPAN http://search.cpan.org/dist/Convert-Ascii85/ LICENSE AND COPYRIGHT Copyright (C) 2011 Lukas Mai This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information.