: # use perl -*- mode: perl; -*-
###
# This program was written by and is copyright Alec Muffett 1991,
# 1992, 1993, 1994, 1995, and 1996, and is provided as part of the
# Crack v5.0 Password Cracking package.
#
# The copyright holder disclaims all responsibility or liability with
# respect to its usage or its effect upon hardware or computer
# systems, and maintains copyright as set out in the "LICENCE"
# document which accompanies distributions of Crack v5.0 and upwards.
###
eval 'exec perl -Ss $0 "$@"'
	if $runnning_under_some_shell;

sub b64decode
{
    $i = shift;
    $o = "";

    $i =~ s/\=+$//o;
    $i =~ tr!A-Za-z0-9+/!\000-\077!;
    @string = unpack("C*", $i);

    while (($w, $x, $y, $z) = splice(@string, 0, 4))
    {
	$val = ($w << 18) | ($x << 12) | ($y << 6) | $z;
	$a = ($val & 0xff0000) >> 16;
	$b = ($val & 0xff00) >> 8;
	$c = ($val & 0xff);
	$o .= pack("C", $a);
	$o .= pack("C", $b) if (defined($y));
	$o .= pack("C", $c) if (defined($z));
    }

    $o;
}

while (<>)
{
    s/\s+$//o;
    unless (/^[A-Za-z0-9\+\/\=]+$/o)
    {
	print STDERR " >$_\n" if ($debug); # "-debug" cmdline switch
	next;
    }
    print &b64decode($_);
}

exit 0;
