Search code examples
c#convertersencoderdecoder

Convert byte[] to string like this "AAAAADT4RyQ="


There is byte array: { 0, 0, 0, 0, 52, 246, 141, 6 }

It somehow represented as a string: AAAAADT4RyQ=

How to do it? What is the encoder?


Solution

  • Looks like base64 encoding to me:

    string base64 = Convert.ToBase64String(data);
    

    That doesn't give quite the results you're expecting though - it gives AAAAADT2jQY=.

    The base64 string you've given corresponds to { 0, 0, 0, 0, 52, 248, 71, 36 } - without more information about where this data is coming from, or how you got the expected value, it's impossible to explain the discrepancy.