473,386 Members | 1,804 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,386 software developers and data experts.

Parsing Base64 encoding

LP
A web service returns base64 encoded data. The goal is to parse it and store
it into binary file with .dat extension. This file is then will be used by a
custom program to produce diagrams. As far as I know base64 data is not any
known graphic format, from what I understand it's just encoded stream of
bytes. Which I need to write to .dat file. Where to start? any links or
suggestions?

Thank you.
Nov 17 '05 #1
5 7546
Have you tried this?

Declare the element in question in the XML schema for the Web Service
as being "base64Binary".

Load the results of the Web Service call into a DataSet. The resulting
DataColumn should have a type of Byte and the byte array it contains
should be the binary version of the base 64 encoding in the XML.

Failing that, I did write my own base64 encoding class that I could
pass along.

Nov 17 '05 #2
If you care just saving the bytes into the file, use FileStream class
provided by .net. It provides a Write method that accepts a byte array
as a parameter (byte array would be your base64 data).

If you need to decode base64 encoded data, simple use
Convert.ToBase64String() method which is also provided by the framework.
base64 is nothing special, just bytes which values are limited by the
set of characters that belong to base64 encoding.

Does that answer your question?
Nov 17 '05 #3
If you care just saving the bytes into the file, use FileStream class
provided by .net. It provides a Write method that accepts a byte array
as a parameter (byte array would be your base64 data).

If you need to decode base64 encoded data, simple use
Convert.ToBase64String() method which is also provided by the framework.
base64 is nothing special, just bytes which values are limited by the
set of characters that belong to base64 encoding.

Does that answer your question?
Nov 17 '05 #4
As the other posters have hinted at, you just need to use the Convert
class and a way to write the data to disk (FileStream works nicely).

Assuming your base64 data is in a string named receivedBase64string, and
you want to write it to the file c:\received.data

using System.IO;
byte[] rawData = Convert.FromBase64String(receivedBase64string);
using (FileStream fs = new FileStream(
@"c:\received.dat",
FileMode.Create))) {
fs.Write(rawData, 0, rawData.Length);
}
Joshua Flanagan
http://flimflan.com/blog
LP wrote:
A web service returns base64 encoded data. The goal is to parse it and store
it into binary file with .dat extension. This file is then will be used by a
custom program to produce diagrams. As far as I know base64 data is not any
known graphic format, from what I understand it's just encoded stream of
bytes. Which I need to write to .dat file. Where to start? any links or
suggestions?

Thank you.

Nov 17 '05 #5
LP
That's easier than I thought, thanks everyone!
"Joshua Flanagan" <jo**@msnews.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
As the other posters have hinted at, you just need to use the Convert
class and a way to write the data to disk (FileStream works nicely).

Assuming your base64 data is in a string named receivedBase64string, and
you want to write it to the file c:\received.data

using System.IO;
byte[] rawData = Convert.FromBase64String(receivedBase64string);
using (FileStream fs = new FileStream(
@"c:\received.dat",
FileMode.Create))) {
fs.Write(rawData, 0, rawData.Length);
}
Joshua Flanagan
http://flimflan.com/blog
LP wrote:
A web service returns base64 encoded data. The goal is to parse it and store it into binary file with .dat extension. This file is then will be used by a custom program to produce diagrams. As far as I know base64 data is not any known graphic format, from what I understand it's just encoded stream of
bytes. Which I need to write to .dat file. Where to start? any links or
suggestions?

Thank you.

Nov 17 '05 #6

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

Similar topics

0
by: SPG | last post by:
Hi, I have an application that is sending out emails to my clients. Some mails are text based and some are html based depending on their preferences. Text emails are fine. I am setting up...
3
by: wenmang | last post by:
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...
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: 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,...
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....
3
by: Cuong.Tong | last post by:
Greeting, I am writing my own web server and having some problme parsing the the mulitpart/form-data stream that is sent from the browsers. I have a form looks something like this <form...
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...
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...
10
by: pycraze | last post by:
Hi , I am currently trying to implement base64 encoding and decoding scheme in C . Python has a module , base64 , that will do the encoding and decoding with ease . I am aware of OpenSSL having...
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: 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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
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...

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.