Howto do Base64 Decoding on OSX
Update: cleaned up to ensure stuff wasn't being treated as tags.
On odd occasions there is a need to do Base64 decoding to view a file.
One example is to view an attachment that is available on a mailing list archive. Say for example, something like this from a Crypto group.
This can be pretty easy to do if you know the right magic on a real operating system (unix backed).
1) copy and paste the output into a file 2) openssl base64 -d <inputfile >out.pdf 3) grin merrily… there is no step 3 (like Instiki).
(For those interested — the OS X post is cause I switched :)… I have a G4 iBook and I am loving it :)).
October 27th, 2005 at 10:25 pm
Hey Rob
Congratulations are in order for the arrival of Isaac and for switching to OS X too!
Thanks for sharing the tip
Cheers,
Franck
May 22nd, 2007 at 7:32 pm
This:
openssl base64 -d -in noname
Results in this:
unknown option ‘noname’
This:
openssl base64 -d -in noname
Results in this:
encode.c(262): OpenSSL internal error, assertion failed: n enc_data
Abort trap
I’ll just ask the sender to re-send an archive (zip).
May 28th, 2007 at 4:18 am
Chuck — the error (not at all friendly I agree) is probably caused by the input file not quite being exactly what openssl was looking for.
The base64 encoded information starts after the content-transfer encod and other content lines (including a blank line).
It goes until there is an end of content type marker (something like –=-+6CkMdvZE6LkzVsMp5qp– ).
June 6th, 2008 at 4:27 am
Hi Rob, running 10.5.2 here.
I also got the abort trap error, and simply encoded a file to see “what openssl was looking for” as you say. In fact, it wants pure Base64 with no header or footer info. I stripped all the content marker stuff from the top and bottom of the (text) file and it worked perfectly. Obviously openssl isn’t coded to actually look for or create anything by default except the encoding.
Really glad I don’t have to do this often, because there’s *absolutely* no good OSX app for it. In the PC world, WinZip works like a charm. Ah well, that’s what Parallels is for!
-L
June 6th, 2008 at 4:38 am
Hey Lucas,
Thanks for the response, and slightly more coherant explanation of the behaviour.
-R