r/dailyprogrammer • • Sep 01 '12
[9/01/2012] Challenge #94 [intermediate] (Base64 conversion)
Create a function which accepts a byte array and outputs a Base64 equivalent of the parameter. Write a second function that reverses the progress, decoding a Base64 string.
Obviously, you can't use a library function for the encode/decode.
(This challenge was posted to /r/dailyprogrammer_ideas by /u/Thomas1122. Thanks for the submission!)
7
Upvotes
2
u/darkgray Oct 13 '12 edited Oct 13 '12
Go
Output
3
u/ananthakumaran Sep 01 '12
C
3
u/skeeto -9 8 Sep 02 '12
In ANSI C,
Example,
1
u/robotfarts Sep 01 '12
1
u/prondose 0 0 Sep 02 '12 edited Sep 02 '12
Perl:
1
u/ixid 0 0 Sep 02 '12 edited Sep 02 '12
D language:
1
u/[deleted] Sep 02 '12
In Python
and it makes
1
u/PiereDome Sep 03 '12
Javascript ('dirty, but works')
1
u/Glassfish 0 0 Sep 03 '12
I'm still trying to learn Python, so i don't know if some portion of code could be written in a more easy way.
0
u/lawlrng 0 1 Sep 01 '12 edited Sep 02 '12
Python 3
Output:
Newlines added to improve readability on reddit.