Back to task

282 symbols perl
Tue Sep 3 13:45:18 2013 Logioniz
#!/usr/bin/perl  -nl
chomp;
$_ = pack 'H*', $_;
$rem = (3 - (length) % 3) % 3;
$_ .= chr(0) x ($rem);
$c=join '', unpack 'B*', $_;
my $res;
for $a ($c=~/.{6}/g) {
	$res .= ['A'..'Z', 'a'..'z',0..9,'+','/']->[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