libmath-base85-perl-0.2+dfsg.orig/0000755000175000017500000000000011647315002016167 5ustar gregoagregoalibmath-base85-perl-0.2+dfsg.orig/test.pl0000644000175000017500000000116307325350143017507 0ustar gregoagregoause strict; use Math::BigInt; use Test; BEGIN { plan tests => 5; } use Math::Base85; ok(1); # Stealing values from RFC 1924. my $n = new Math::BigInt("21932261930451111902915077091070067066"); my $m = Math::Base85::to_base85($n); ok($m, "4)+k&C#VzJ4br>0wv%Yp"); # Supply some invalid stuff. my $x = qq("anbukrvq35490ASRVKOAMRS"); eval { my $y = Math::Base85::from_base85($x); }; ok($@); ok($@, qr/invalid base 85 digit/); # Add 1 and see if we get what we expect. my $p = "4)+k&C#VzJ4br>0wv%Yq"; my $q = Math::Base85::from_base85($p); my $r = new Math::BigInt("21932261930451111902915077091070067067"); ok($q == $r); libmath-base85-perl-0.2+dfsg.orig/Makefile.PL0000644000175000017500000000035507325337772020164 0ustar gregoagregoause ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'Math::Base85', 'VERSION_FROM' => 'Base85.pm', # finds $VERSION ); libmath-base85-perl-0.2+dfsg.orig/Changes0000644000175000017500000000050407524040070017460 0ustar gregoagregoaRevision history for Perl extension Math::Base85. 0.2 Fri May 03 09:11:41 PDT 2002 - Initial zeroes fix from Jyrki Soini . 0.1 Fri Jul 20 17:11:22 PDT 2001 - to_base85 and from_base85 work, and can be exported. - $Math::Base85::base85_digits made available to other modules. libmath-base85-perl-0.2+dfsg.orig/Base85.pm0000644000175000017500000000467307524035657017604 0ustar gregoagregoapackage Math::Base85; use strict; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $base85_digits); use Carp; use Exporter; use Math::BigInt qw(:constant); $VERSION = '0.2'; @ISA = qw(Math::BigInt); @EXPORT = qw(); @EXPORT_OK = qw(from_base85 to_base85); =head1 NAME Math::Base85 - Perl extension for base 85 numbers, as referenced by RFC 1924 =head1 SYNOPSIS use Math::Base85; $bigint = from_base85($number); $b85str = to_base85($bigint); =head1 DESCRIPTION RFC 1924 describes a compact, fixed-size representation of IPv6 addresses which uses a base 85 number system. This module handles some of the uglier details of it. The base 85 numbers (from 0 to 84) are as follows: 0..9 A..Z a..z ! # $ % & ( ) * + - ; < = > ? @ ^ _ ` { | } ~ At the moment, there's not much in this module. But it should be sufficient for the purposes of RFC 1924. This module has a variable called C<$Math::Base85::base85_digits>, which is a string containing the digits of the base 85 alphabet from lowest (0) to highest (~), in that order. Additionally, the following two functions are defined for general use. (They will be exported upon request.) =cut $Math::Base85::base85_digits = join('', '0' .. '9', 'A' .. 'Z', 'a' .. 'z', '!', '#', qw/$ % & ( ) * + - ; < = > ? @ ^ _ ` { | } ~/, ); # Maybe we can make this a little more general... use constant B85_BASE => 85; =pod =head1 from_base85 =head2 Parameters A string composed of valid base 85 digits. =head2 Returns A C object representing the number. =cut sub from_base85 { my $num = shift; my @digits = split(//, $num); my $answer = new Math::BigInt "0"; my $n; my $d; while (defined($d = shift @digits)) { $answer = $answer * B85_BASE; $n = index($base85_digits, $d); if ($n < 0) { croak __PACKAGE__ . "::from_base85 -- invalid base 85 digit $d"; } $answer = $answer + $n; } return $answer; } =pod =head1 to_base85 =head2 Parameters A C object. =head2 Returns A string of base 85 digits representing the number. =cut sub to_base85 { my $num = shift; my @digits; my $q; my $r; my $d; while ($num > 0) { $q = $num / B85_BASE; $r = $num % B85_BASE; $d = substr($base85_digits, $r, 1); unshift @digits, $d; $num = $q; } unshift @digits, '0' unless (@digits); return join('', @digits); } =head1 AUTHOR Tony Monroe =head1 SEE ALSO perl(1). =cut 1; __END__ libmath-base85-perl-0.2+dfsg.orig/README0000644000175000017500000000140707524040110017043 0ustar gregoagregoa======================== Math::Base85 Version 0.2 ======================== This module handles numbers in base 85, via strings and Math::BigInt. For more information, read the module or rfc1924.txt. The usual installation instructions apply: /path/to/perl Makefile.PL make make test make install Please report bugs to the author at . --------------------- Copyright and License --------------------- This distribution (with the exception of any included RFC's) is copyright (c) 2001-2002 Tony Monroe. All rights reserved. This software is distributed under the same license terms as Perl itself. This software comes with NO WARRANTIES WHATSOEVER, express, implied, or otherwise. $Id: README,v 1.3 2002/08/06 21:31:52 tony Exp $ libmath-base85-perl-0.2+dfsg.orig/MANIFEST0000644000175000017500000000006611647315002017322 0ustar gregoagregoaBase85.pm Changes MANIFEST Makefile.PL test.pl README