Page 1 of 1

.B64 file format

Posted: 21 Oct 2006, 15:02
by SvA
I have got a base64 encoded data stream embeded in an XML file, which I like to decode.

I copied the data into a new file and gave it the extension .b64, but Servant Salamander created only an empty folder on extraction.

I then searched the Internet for a file format specification for .b64 files, but could not find any.

Would you please point me in the right direction.

Re: .B64 file format

Posted: 21 Oct 2006, 15:27
by Jan Patera
SvA wrote:I have got a base64 encoded data stream embeded in an XML file, which I like to decode.
I copied the data into a new file and gave it the extension .b64, but Servant Salamander created only an empty folder on extraction.

I then searched the Internet for a file format specification for .b64 files, but could not find any.
Would you please point me in the right direction.
If you want the UnMime plugin to recognized Base64-encoded data, precede the data with the following line, followed by one more empty line.
Content-transfer-encoding: BASE64

BASE64 encoding is very simple - every 3 bytes of input data are converted into 4 characters from 64-item alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/". In case the size of the input is not divisible by 3, then the last output quadruplet is padded by '=' signs. E.g.:
ABCDEF== decodes as 0x00 0x10 0x83 0x10.

Posted: 21 Oct 2006, 19:12
by SvA
Thank you, Jan, for your response.

Adding mime headers and breaking up the character stream into lines of 76 characters according to mime standard was what I did, since it was the UnMIME plugin which felt responsible.

Without breaking up the lines (i.e. just adding the header(s) I got a corrupted image on decoding (without any warning!).

There are many references to the .b64 extension related to base64 encoded data, so I thought there must be also a file specification (similar to a uuencoded file which has a file header) or else the file contains nothing but the encoded data stream (possibly with added white space.

Are there any requirements on a MIME file to be legitimately called .b64 (in general, not limited to Servant Salamander)?

Posted: 21 Oct 2006, 19:24
by Jan Patera
SvA wrote:Are there any requirements on a MIME file to be legitimately called .b64 (in general, not limited to Servant Salamander)?
I don't think there is any standard/recommendation for exact file suffix and/or structure. There is no real reason to have standalone base64-encoded files, the encoding is meant to be transfer encoding, not file storage encoding, although various file formats (such as PostScript or PDF) may use it internally.