#!/usr/bin/perl sub base64_decode( $ ); $chars = ''; while (<>) { y/A-Za-z0-9+\/=//cd; y/A-Za-z0-9+\/=/\000-\100/; $chars .= $_; while (length($chars) >= 4) { print base64_decode $chars; $chars = unpack("x4 a*",$chars); } } sub base64_decode( $ ) { my ($a,$b,$c,$d) = unpack("C4", $_[0]); my $stuff = ($a<<18) | ($b<<12) | ($c<<6) | $d; if ($c == 64) { $stuff = pack("C", ($stuff >> 16) & 255); } elsif ($d == 64) { $stuff = pack("CC", ($stuff >> 16) & 255, ($stuff >> 8) & 255); } else { $stuff = pack("CCC", ($stuff >> 16) & 255, ($stuff >> 8) & 255, $stuff & 255); } $stuff; } .