Server IP : 103.119.228.120 / Your IP : 18.227.52.248 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/ssl/local/ssl/local/ssl/local/ssl/local/share/perl5/Math/ |
Upload File : |
package 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<Math::BigInt> 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<Math::BigInt> 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 <tmonroe+perl@nog.net> =head1 SEE ALSO perl(1). =cut 1; __END__