|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
String to byte[] & back using Base64Hi,
Can I please have a very small code snippet to convert byte[] to string and back using Base64? Advance thanks. -- Samba! Hello Samba,
string b = Convert.ToBase64String(bytes); byte[] bytesagain = Convert.FromBase64String(b); --------------------------------------- Dominick Baier - DevelopMentor http://www.leastprivilege.com Show quoteHide quote > Hi, > > Can I please have a very small code snippet to convert byte[] to > string and back using Base64? Advance thanks. >
Show quote
Hide quote
"Dominick Baier [DevelopMentor]" wrote: I'm using this functionality to try to load an image that's returned to me > 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. > > > > > > 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? Hello Steve,
From/To base64 conversion is lossless... not sure what your problem is. --------------------------------------- Dominick Baier - DevelopMentor http://www.leastprivilege.com Show quoteHide quote > "Dominick Baier [DevelopMentor]" wrote: > >> 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. >>> > 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? >
Show quote
Hide quote
> I'm using this functionality to try to load an image that's returned to me arrImg...is your bytearray ;-)> 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? 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
X509 digital certificate for offline solution
Authorization against AD using MC++ Bad Data error in DES encryption Securing a control assembly against use of foreign assemblies sn.exe exit code documentation ? Why defaultcredential doesn't use the impersonated user? Java security api - DCE 128bit encryption with .NET SecurityException: Request Failed on CreateInstanceAndUnwrap Create an Event Log on a Least Privilege User Account Decrypt file in VB6 encrypted in vb.net |
|||||||||||||||||||||||