Back to task

329 symbols perl
Sun Sep 1 16:46:18 2013 Logioniz
#!/usr/bin/perl  -n
chomp;
$_ = pack 'H*', $_;
$rem = (3 - (length) % 3) % 3;
$_ .= chr(0) x ($rem);
$c=join '', unpack 'B*', $_;
$res ='';
for $a ($c=~/.{6}/g) {
	$res .= [split //,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/']->[unpack 'C', pack 'B*', '00'. $a];
}
$rep = '=' x $rem;
$res =~ s/A{$rem}$/$rep/;
print $res,$/;


Leave a comment

Parsed as Markdown

Login to leave a comment