473,698 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5392
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.goo gle.com...
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.t eranews.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.goo gle.com...
"Dennis E. Hamilton" <de************ *@acm.org> wrote in message

news:<82******* *************** ********@news.t eranews.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
537
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 this private string ConvertBase64ToString(string content) { StringBuilder sb = new StringBuilder(); int i = content.GetUpperBound(0);
2
8692
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 attachment. If I try and open the original PDF file I have no problems. I have used System.Web.Mail.MailMessage to create an email and an SMTPMail object to send the mail.
2
29316
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, but the instructions I received do not seem correct. I need to covert a hex string to base64 and was told to 1. convert from the HEX string to a byte array 2. convert the byte array to Base64 encoding 3. the two encodings would produce the...
12
7782
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, nor opening a second box for display of the progress bar. I had been using the MegaUpload that was adapted from Raditha's script at http://www.raditha.com/upload.php . The MegaUpload script I have been using takes the progress bar inpage,...
5
4117
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. Cold somebody check this for me to see what I have done wrong: If you run this program and enter a path for a .GIF file into the white box and hit <Enter> it should display the string in the blue box. To test this if you click the menu File...
11
4755
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 in japanese. But I am unable to display them back to GUI. It displays some junk characters Can anyone suggest me some way how to debug the issue. The code used for tranferring data from view to document is: " codec =...
8
2800
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 the result should be "pass____ what the result is where each underline char is a nothing char. I am about to write a function that will remove the nothing chars butI would like to know what is causing the problem and simply avoid it
3
8287
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 build with these methods, will appear to encrypt and decrypt, but the resulting decrypted file will be corrupted. I tried encrypting a .bmp file and then decrypting, the resulting decrypted file under .NET 2.0 is garbage, the .NET 1.1 build works...
13
14778
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 send me the library file which helps that is really grateful. aruna.
0
8678
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9166
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.