473,387 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

trade off by using Base64 encoding

Hi,
I ma thinking whether to use Base64 encoding to encode the binary
content in the XML file. I have done some simple calculations, it
seems to me that the size for encoded content increases by ~30%, is
this the drawback for using the encoding scheme?
Thanks.
Jul 20 '05 #1
3 5371
By my math, you will use 32 bits for every 24 encoded (4 base64 characters
(bytes) for 3 octets (bytes) worth of bits, or exactly 1-1/3 times the
space required for the raw bits.

Since there's no commonly-available, safe alternative for carrying binary
data in XML elements, I suppose you should be asking "drawback relative to
what?"

(If the binary is compressible, you might do that before Base64 encoding.
But that adds more to what the recipient is required to do.)

-- orcmid

"wenmang" <we*****@yahoo.com> wrote in message
news:9f**************************@posting.google.c om...
Hi,
I ma thinking whether to use Base64 encoding to encode the binary
content in the XML file. I have done some simple calculations, it
seems to me that the size for encoded content increases by ~30%, is
this the drawback for using the encoding scheme?
Thanks.

Jul 20 '05 #2
"Dennis E. Hamilton" <de*************@acm.org> wrote in message news:<82******************************@news.terane ws.com>...
By my math, you will use 32 bits for every 24 encoded (4 base64 characters
(bytes) for 3 octets (bytes) worth of bits, or exactly 1-1/3 times the
space required for the raw bits. I am on HPUX11, could I use 4 base64 chars to encode 4 octets? is this
doable or 1-1/3 ratio is always the case?
Since there's no commonly-available, safe alternative for carrying binary
data in XML elements, I suppose you should be asking "drawback relative to
what?" I use a wrong word, I should ask "is the price to pay for encoding the
binary content?"
I am wondering whether 1 to 1 byte to byte encoding is possbile using
base64 for binary encoding without incurring the increasing in size?
(If the binary is compressible, you might do that before Base64 encoding.
But that adds more to what the recipient is required to do.)

-- orcmid

Jul 20 '05 #3
In Base 64 encoding, there are only 64 characters used per octet (not
counting white space and other things that don't count). That gives you 6
bits of encoded material. The only way to encode 24 bits of material (3
full octets) is with 4 Base 64 characters. You will always use 4 octets to
encode 3.

The whole reason for this is to be able to use a channel that will likely
preserve those 64 different character encodings, in traveling end-to-end,
without loss or disruption. That's the price. The machine and operating
system you are on has nothing to do with it.

-- orcmid

"wenmang" <we*****@yahoo.com> wrote in message
news:9f**************************@posting.google.c om...
"Dennis E. Hamilton" <de*************@acm.org> wrote in message

news:<82******************************@news.terane ws.com>...
By my math, you will use 32 bits for every 24 encoded (4 base64 characters (bytes) for 3 octets (bytes) worth of bits, or exactly 1-1/3 times the
space required for the raw bits.

I am on HPUX11, could I use 4 base64 chars to encode 4 octets? is this
doable or 1-1/3 ratio is always the case?
Since there's no commonly-available, safe alternative for carrying binary data in XML elements, I suppose you should be asking "drawback relative to what?"

I use a wrong word, I should ask "is the price to pay for encoding the
binary content?"
I am wondering whether 1 to 1 byte to byte encoding is possbile using
base64 for binary encoding without incurring the increasing in size?

(If the binary is compressible, you might do that before Base64 encoding. But that adds more to what the recipient is required to do.)

-- orcmid

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: mvdevnull | last post by:
hey all currently i use the following piece of code to check if the string passed to me can be converted to base64, it is not very efficient and bad, can someone please suggest another of doing...
2
by: New User | last post by:
Hi, I have a PDF file that I am trying to send as an attachment through a C# program. Even though the PDF file can be opened by itself, sometimes the same file cannot be opened as an...
2
by: kevin | last post by:
DISCLAIMER: I know what the words mean (i.e. by definition), but I in know way pretend to understand the specifics of either, therefore I may need a basic primer before I can accomplish this task,...
12
by: JMB | last post by:
Hello, I was wondering if anyone knew of any projects extending the inline upload progress bar to utilize an inpage image uploader with bar, without having to refresh or go to a seperate page,...
5
by: Jay | last post by:
I have bean trying to get my head around reading .GIF files from base64 strings, Basically I need to specify a filename and convert it to base64 then I can copy/past the string to wear I want it....
11
by: prats | last post by:
I want to write a GUI application in PYTHON using QT. This application is supposed to take in Japanese characters. I am using PyQt as the wrapper for using QT from python. I am able to take input...
8
by: Jeremy Kitchen | last post by:
I have encoded a string into Base64 for the purpose of encryption. I then later decrypted it and converted it back from Base64 the final string returns with four nothing characters. "pass" what...
3
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
13
by: aruna.eies.eng | last post by:
i am currently trying to convert data into binary data.for that i need to know how to achieve it in c language and what are the libraries that we can use. so if any one can send me a sample code or...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.