BreakHead
BreakHead

Reputation: 10672

Get string value from a byte string

I have to get the value from byte string this is the byte string

4W3CfJ//nw1CpeA5NfXx9Ia32JyVmgpRrQCzUabFUvv0fqXYLVeNBT6XKjBehFNGtQ3Sng3Zucqu+RcXUzJ3KA==

now how can I get the value from it

Upvotes: 0

Views: 4877

Answers (4)

abhilash
abhilash

Reputation: 5651

If the byte array is an UTF encoded byte array it can be converted using

UTF8Encoding encoder = new UTF8Encoding(); 
encoder.GetString(bytes);

Upvotes: 0

Shekhar_Pro
Shekhar_Pro

Reputation: 18430

Its an Base64 Encoded string you will need to get back the UnEncoded string like this:

 byte[] b = Convert.FromBase64String("your base 64 string==");

 originalString = System.Text.Encoding.UTF8.GetString(b);

Upvotes: 6

Aliostad
Aliostad

Reputation: 81690

Use

Byte[] bytes = Convert.FromBase64String(myString);

Upvotes: 2

DRapp
DRapp

Reputation: 48169

Look into encoding, but it might be as simple as

YourString = Encoding.ASCII.GetBytes( YourByteArrayString );

Upvotes: 0

Related Questions