Call it reverse engineering the book. Larry has a base64-to-uuencode
converter in the cammel book, and I needed the reverse so I could
build a client to the Velar Central Archive. So here's a few
subroutines I built to help out. (And unlike mhttpd, it's more perl
translating than looping)
# Convert data to base64
sub base64 {
my($line)=@_;
my($r);
$r=pack "u",$line;
$r=~ s/^.(.+)$/$1/;
$r=~ tr# -_#A-Za-z0-9+/#;
return $r;
}
# base64 back to reality
sub unbase64 {
my($line)=@_;
my($r);
$line =~ tr#A-Za-z0-9+/##cd;
$line =~ tr#A-Za-z0-9+/# -_#;
$r=pack("c", 32 + 0.75*(length $line));
return unpack("u", $r . $line);
}