Base64 encode from hex

Encode base64 using rules from this rfc2045.
You must to do this: 
print base64(unhex($input));

IN

D35DB7E39EBBF3D001083105
1440C2040F7CEFAE78DF6D74
0123456789ABCDEF
FEDCBA9876543210
AAAAAABBBBBBCCCCCC
41424344
FFFF

OUT

0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=

IN

D35DB7E39EBBF3D001083105

OUT

0123456789ABCDEF

IN

1440C2040F7CEFAE78DF6D74

OUT

FEDCBA9876543210

IN

0123456789ABCDEF

OUT

ASNFZ4mrze8=

IN

FEDCBA9876543210

OUT

/ty6mHZUMhA=
Login to submit solution


327 symbols perl failed test 1 Wrong answer
0123456789ABCDEFFEDCBA9876543210ASNFZ4mrze8=/ty6mHZUMhA=qqqqu7u7zMzMQUJDRA==//8=
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Sun Sep 1 16:45:01 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;
74 symbols perl failed test 1 Wrong answer
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Wed Sep 4 09:32:01 2013 avkhozov
#!/usr/bin/perl -n
use MIME::Base64 'encode_base64';
chomp&&print encode_base64 pack'H*',$_
223 symbols perl failed test 1 Wrong answer
AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA
AAAAAAAAA=
AAAAAAAAA=
AAAAAAAAAAAA
AAA==
A=
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Wed Sep 4 19:55:02 2013 Logioniz
#!/usr/bin/perl  -nl
chomp;$_=pack 'H*', $_;$r=(3-(length)%3)%3;$_ .= chr(0)x($rem);$c=join '',unpack 'B*',$_;my $t;$t .=['A'..'Z', 'a'..'z',0..9,'+','/']->[unpack 'C',pack 'B*','00'.$a] for $c=~/.{6}/g;$p ='='x$r;$t=~ s/A{$r}$/$p/;print $t;
52 symbols perl failed test 1 Wrong answer
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//A=
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Fri Jan 10 18:50:00 2014 bugov
#!/usr/bin/perl -p
use MIME::Base64;chop;$_=encode_base64 pack'H*',$_
50 symbols perl failed test 1 Code error

Too late for "-MMIME::Base64" option at ./code line 1.

Mon Jun 16 10:14:08 2014 avkhozov
#!/usr/bin/perl -MMIME::Base64 -p
chom;$_=encode_base64 pack'H*',$_
52 symbols perl failed test 1 Wrong answer
0123456789ABCDEFoA==
FEDCBA9876543210oA==
ASNFZ4mrze+g
/ty6mHZUMhCg
qqqqu7u7zMzMoA==
QUJDRKA=
//8=
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Mon Jun 16 10:15:19 2014 avkhozov
#!/usr/bin/perl -p
use MIME::Base64;chom;$_=encode_base64 pack'H*',$_
34 symbols ruby2.0 failed test 1 Wrong answer
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//A=
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Mon Jun 16 10:49:47 2014 avkhozov
#!/usr/bin/ruby2.0 -pl
$_=[[$_].pack("H*")].pack("m0")
34 symbols ruby2.0 failed test 1 Wrong answer
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//A=
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Mon Jun 16 10:50:31 2014 avkhozov
#!/usr/bin/ruby1.9.1 -lp
$_=[[$_].pack("H*")].pack("m0")
42 symbols ruby2.0 failed test 1 Wrong answer
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//A=
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Mon Jun 16 10:56:57 2014 avkhozov
#!/usr/bin/ruby2.0 -lp
$_=[[$_.chomp()].pack("H*")].pack("m0")
38 symbols ruby2.0 failed test 1 Wrong answer
//8=
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Mon Jun 16 11:00:27 2014 avkhozov
print [["FFFF"].pack("H*")].pack("m0")
40 symbols ruby2.0 failed test 1 Wrong answer
//+g
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Mon Jun 16 11:01:20 2014 avkhozov
print [["FFFF\n"].pack("H*")].pack("m0")
44 symbols ruby2.0 failed test 1 Wrong answer
0123456789ABCDEFFEDCBA9876543210ASNFZ4mrze8=/ty6mHZUMhA=qqqqu7u7zMzMQUJDRA==//8=
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Mon Jun 16 11:02:27 2014 avkhozov
#!/usr/bin/ruby2.0 -n
print [[$_.chomp()].pack("H*")].pack("m0")
45 symbols ruby2.0 failed test 1 Wrong answer
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//A=
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Mon Jun 16 11:02:58 2014 avkhozov
#!/usr/bin/ruby2.0 -ln
print [[$_.chomp()].pack("H*")].pack("m0")
45 symbols ruby2.0 failed test 1 Wrong answer
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//A=
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Sat Jul 5 13:07:55 2014 Nakilon
$<.map{|i|puts [[i.chop].pack('H*')].pack'm'}
45 symbols ruby2.0 failed test 1 Wrong answer
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//A=
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Sat Jul 5 13:09:29 2014 Nakilon
$<.map{|i|puts [[i.chop].pack('H*')].pack'm'}
34 symbols perl failed test 1 Wrong answer
QUI=
QUJD
QUJDRA==
//8=
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Tue Jul 29 14:29:55 2014 vik
print "QUI=\nQUJD\nQUJDRA==\n//8="
26 symbols php failed test 1 Wrong answer
QUI=\nQUJD\nQUJDRA==\n//8=
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Fri Aug 1 17:03:35 2014 PixelIndigo
QUI=\nQUJD\nQUJDRA==\n//8=
34 symbols bash failed test 1 Wrong answer
QUI=\nQUJD\nQUJDRA==\n//8=
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Fri Aug 1 17:20:22 2014 PixelIndigo
echo $"QUI=\nQUJD\nQUJDRA==\n//8="
34 symbols bash failed test 1 Wrong answer
QUI=
QUJD
QUJDRA==
//8=
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Fri Aug 1 17:20:53 2014 PixelIndigo
echo $'QUI=\nQUJD\nQUJDRA==\n//8='
23 symbols php failed test 1 Wrong answer
QUI=
QUJD
QUJDRA==
//8=
instead of
0123456789ABCDEF
FEDCBA9876543210
ASNFZ4mrze8=
/ty6mHZUMhA=
qqqqu7u7zMzM
QUJDRA==
//8=
Fri Aug 1 19:05:54 2014 vik
QUI=
QUJD
QUJDRA==
//8=

View all solutions