Back to task

283 symbols perl
Mon Sep 2 16:27:57 2013 avkhozov
#!/usr/bin/perl  -nl
chomp;
$_ = pack 'H*', $_;
$rem = (3 - (length) % 3) % 3;
$_ .= chr(0) x ($rem);
$c=join '', unpack 'B*', $_;
$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