Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Security / October 2005

Tip: Looking for answers? Try searching our database.

String to byte[] & back using Base64

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Samba - 08 Aug 2005 06:21 GMT
Hi,

Can I please have a very small code snippet to convert byte[] to string and
back using Base64? Advance thanks.

Signature

Samba!

Dominick Baier [DevelopMentor] - 08 Aug 2005 09:19 GMT
Hello Samba,

string b = Convert.ToBase64String(bytes);
byte[] bytesagain = Convert.FromBase64String(b);

---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com

> Hi,
>
> Can I please have a very small code snippet to convert byte[] to
> string and back using Base64? Advance thanks.
Samba - 08 Aug 2005 09:39 GMT
Ok, so thats how you do it ... thanks, Dominick.
Signature

Samba!

Steve Smith - 25 Oct 2005 16:45 GMT
> Hello Samba,
>
[quoted text clipped - 9 lines]
> > Can I please have a very small code snippet to convert byte[] to
> > string and back using Base64? Advance thanks.

I'm using this functionality to try to load an image that's returned to me
in an XML file. The converstion to the byte array works fine.

Than I move the byte array into a memory Stream using ...

Dim stmBLOBData As New MemoryStream(binaryData)

which also seems to work fine, but the following line which should actually
create the image failes with a "Invalid Parameter used".

    img =  Image.FromStream(stmBLOBData)

Is this really a problem with my conversion? Any ideas how to debug?
Dominick Baier [DevelopMentor] - 25 Oct 2005 17:25 GMT
Hello Steve,

From/To base64 conversion is lossless...

not sure what your problem is.

---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com

>> Hello Samba,
>>
[quoted text clipped - 21 lines]
>
> Is this really a problem with my conversion? Any ideas how to debug?
Marcello Cantelmo - 25 Oct 2005 23:47 GMT
> I'm using this functionality to try to load an image that's returned to me
> in an XML file. The converstion to the byte array works fine.
[quoted text clipped - 10 lines]
>
> Is this really a problem with my conversion? Any ideas how to debug?

arrImg...is your bytearray ;-)

Dim _stream As New MemoryStream(_arrImg, True)
stream.Write(_arrImg, 0, _arrImg.Length)
PictureBox1.Image = New Bitmap(New Bitmap(_stream))
_stream.Close()

best regards,
Marcello Cantelmo
www.cantelmosoftware.com

try for free Goliath.NET Obfuscator - the last secure obfuscator for .NET
platform

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.