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


36 symbols ruby2.0
Sun Oct 2 07:15:12 2016 Sait2000
#!/usr/bin/ruby2.2 -p
$_=[[$_.chomp].pack("H*")].pack ?m
37 symbols ruby2.0
Mon Jun 16 11:17:00 2014 avkhozov
#!/usr/bin/ruby2.0 -p
$_=[[$_.chomp].pack("H*")].pack "m"
38 symbols ruby2.0
Mon Jun 16 11:15:47 2014 avkhozov
#!/usr/bin/ruby2.0 -p
$_=[[$_.chomp].pack("H*")].pack("m")
40 symbols ruby2.0
Mon Jun 16 11:13:18 2014 avkhozov
#!/usr/bin/ruby2.0 -p
$_=[[$_.chomp()].pack("H*")].pack("m")
46 symbols ruby2.0
Sat Jul 5 13:10:43 2014 Nakilon
$<.map{|i|puts [[i.chomp].pack('H*')].pack'm'}
46 symbols ruby2.0
Fri Mar 20 07:10:41 2015 lasteye
$<.map{|i|puts [[i.chomp].pack('H*')].pack'm'}
46 symbols ruby2.0
Fri Mar 20 07:10:41 2015 lasteye
$<.map{|i|puts [[i.chomp].pack('H*')].pack'm'}
46 symbols pyth
Wed Oct 19 14:05:37 2016 Sait2000
V.z.[sm@s+++rG1GUT"+/"i.[d\06 2ct.Bi+1N16 6\=4
50 symbols pyth
Tue Sep 27 10:17:18 2016 Sait2000
V.z.[sm@s+++rG1GUT"+/"i.[d\06 2csm.[\04.Bid16N6\=4
53 symbols perl
Fri Jan 10 18:50:43 2014 bugov
#!/usr/bin/perl -p
use MIME::Base64;chomp;$_=encode_base64 pack'H*',$_
71 symbols bash
Wed Jul 27 03:35:34 2016 hidefromkgb
echo -e "`sed 's/[^\n]./\\\x&/g'`"|xargs -I% sh -c 'echo -n "%"|base64'
82 symbols python2
Sat Oct 15 16:07:50 2016 Sait2000
from base64 import*
try:
 while 1:print b64encode(b16decode(raw_input()))
except:0
83 symbols python2
Sat Oct 15 16:03:39 2016 Sait2000
import sys,base64 as b
for l in sys.stdin:print b.b64encode(b.b16decode(l.strip()))
85 symbols python2
Sat Oct 15 16:07:27 2016 Sait2000
import base64 as b
try:
 while 1:print b.b64encode(b.b16decode(raw_input()))
except:0
86 symbols python2
Tue Feb 2 01:46:02 2016 unayok
import sys,base64 as b
for l in sys.stdin:
 print b.b64encode(b.b16decode(l.strip()))
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;
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;
309 symbols haskell
Fri Mar 13 21:56:47 2015 YoshikuniJujo
main=interact$unlines.map(s.h).lines
(#)=div
(?)=mod
o=fromEnum
t=['A'..'Z']++['a'..'z']++['0'..'9']++"+/"
i c|o c<58=o c-48|1>0=o c-55
h""=[]
h(a:b:c)=i a*16+i b:h c
s[]=""
s[x]=map(t!!)[x#4,x?4*16]++"=="
s[x,y]=map(t!!)[x#4,x?4*16+y#16,y?16*4]++"="
s(x:y:z:n)=map(t!!)[x#4,x?4*16+y#16,y?16*4+z#64,z?64]++s n
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,$/;

View all solutions