/usr/share/perl5/Mail/SendEasy/Base64.pm is in libmail-sendeasy-perl 1.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | #############################################################################
## Name: Base64.pm
## Purpose: Mail::SendEasy::Base64
## Author: Graciliano M. P.
## Modified by:
## Created: 25/5/2003
## RCS-ID:
## Copyright: (c) 2003 Graciliano M. P.
## Licence: This program is free software; you can redistribute it and/or
## modify it under the same terms as Perl itself
#############################################################################
package Mail::SendEasy::Base64 ;
use strict qw(vars) ;
no warnings ;
use vars qw($VERSION @ISA) ;
our $VERSION = '1.0' ;
require Exporter;
@ISA = qw(Exporter);
our @EXPORT = qw(encode_base64 decode_base64) ;
our @EXPORT_OK = @EXPORT ;
my ($BASE64_PM) ;
eval("use MIME::Base64 ()") ;
if ( defined &MIME::Base64::encode_base64 ) { $BASE64_PM = 1 ;}
#################
# ENCODE_BASE64 #
#################
sub encode_base64 {
if ( $BASE64_PM ) { return &MIME::Base64::encode_base64($_[0]) ;}
else { return &_encode_base64_pure_perl($_[0]) ;}
}
############################
# _ENCODE_BASE64_PURE_PERL #
############################
sub _encode_base64_pure_perl {
my $res = "";
my $eol = $_[1];
$eol = "\n" unless defined $eol;
pos($_[0]) = 0; # ensure start at the beginning
while ($_[0] =~ /(.{1,45})/gs) {
$res .= substr(pack('u', $1), 1);
chop($res);
}
$res =~ tr|` -_|AA-Za-z0-9+/|; # `# help emacs
# fix padding at the end
my $padding = (3 - length($_[0]) % 3) % 3;
$res =~ s/.{$padding}$/'=' x $padding/e if $padding;
# break encoded string into lines of no more than 76 characters each
if (length $eol) {
$res =~ s/(.{1,76})/$1$eol/g;
}
$res;
}
#################
# DECODE_BASE64 #
#################
sub decode_base64 {
if ( $BASE64_PM ) { return &MIME::Base64::decode_base64($_[0]) ;}
else { return &_decode_base64_pure_perl($_[0]) ;}
}
############################
# _DECODE_BASE64_PURE_PERL #
############################
sub _decode_base64_pure_perl {
local($^W) = 0 ;
my $str = shift ;
my $res = "";
$str =~ tr|A-Za-z0-9+=/||cd; # remove non-base64 chars
if (length($str) % 4) {
#require Carp;
#Carp::carp("Length of base64 data not a multiple of 4")
}
$str =~ s/=+$//; # remove padding
$str =~ tr|A-Za-z0-9+/| -_|; # convert to uuencoded format
while ($str =~ /(.{1,60})/gs) {
my $len = chr(32 + length($1)*3/4); # compute length byte
$res .= unpack("u", $len . $1 ); # uudecode
}
$res;
}
#######
# END #
#######
1;
|