KBD

Keith Devens .com

Friday, November 21, 2008 Flag waving
"I am a leaf on the wind. Watch how I soar." – 'Wash' (Serenity, 2005)
← No cents for youA New Kind of Science →

Daily link icon Monday, May 13, 2002

Base64 decoding

I just needed to decode a base64 encoded file. First I tried writing a small script with REBOL's debase function, but that didn't work. REBOL's save function kept saving it in a REBOL-readable form, not in a binary form (I was decoding a PNG), even when I used the /png refinement.

So I went looking for something already written and the first hit on Google was this very useful utility for encoding and decoding base64. Worked right away, no hitch Smiley Thanks John Walker (not that John Walker). He also has a similar utility for encoding and decoding quoted-printable encoding.

← No cents for youA New Kind of Science →

Comments XML gif

M. Bean (http://www.yaysoft.com/) wrote:

You could have also likely used this PHP function:
base64_decode()
http://www.php.net/manual/en/function.base64-decode.php

∴ M. Bean | 13-May-2002 10:53pm est | http://www.yaysoft.com/ | #394

Keith (http://www.keithdevens.com/) wrote:

I was actually thinking of that. I expected it to be trivial in REBOL, so that's why I tried it first. Literally, it should have been:

save %g1.png debase read %g1.png.base64

but that turned out not to work. So I went searching for a utility and immediately found the one I linked to. If I hadn't found anything to do it, I possibly would have gone the PHP route, which would be the next easiest (and probably would have actually worked!)

Keith | 13-May-2002 11:48pm est | http://www.keithdevens.com/ | #395

Alekk wrote:

REBOL:
You should use write/binary, as "save" writes data "for REBOL", and "save/png" converts (and saves) internal rebol image datatype to png.

There should be:
write/binary %g1.png debase read %g1.png.base64

∴ Alekk | 31-Jan-2004 7:38am est | #3850

Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

November 2008
SunMonTueWedThuFriSat
 1
2345678
9101112131415
16171819202122
23242526272829
30 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 5 posts

Recent comments XML

new⇒Calif. Supreme Court to take up gay marriage ban

I would argue the point is not​definitional.  While the word​marriage is su...

Justin: Nov 20, 4:37pm

Java join function

Meh, don't have null strings in​your string arrays imo, but you're​welcome ...

Keith: Nov 19, 7:51pm

Girls, please don't get breast implants

sorry but another thing i have to​make a comment on about you​men...the men...

happynow: Nov 17, 11:36pm

Books by Vincent Cheung

to all Cheung​fans:

read:

http://www.progin​osko.com/aquascum/cheung.h...

Zamir: Nov 16, 9:07am

Spider solitaire

To undo or not to undo that is the​question.
I'm an undoer. 
My dad​was n...

Can Turk: Nov 15, 2:50pm

Generated in about 0.275s.

(Used 8 db queries)

mobile phone