Get proper encoded string value from decoded string

119 Views Asked by At

I want to get proper encoded string value from decoded string.

In my database one column is storing value in this way.

UA8SMvak9gq+mjrj6C6BR9atmlA=

This value is saving from distributed memory caching in database in table.

So I am not sure from where code is generating this string.

Now I want see actual value of this string so I thought it is some Decoded string, so I tried below to see encoded string but that encoded value does not looks good.

byte[] data = Convert.FromBase64String("UA8SMvak9gq+mjrj6C6BR9atmlA=");
string decodedString = Encoding.UTF8.GetString(data);

It's encoded string looks like this :

"P\u000f\u00122���\n��:��.�G֭�P"

Any idea on this Like how I can get proper encoded string.

1

There are 1 best solutions below

0
ioi On

All common encoding decoded results showed invalid characters. So the original data should be binary data. It might be encrypted string or it might not be string at all.

byte[] data = Convert.FromBase64String("UA8SMvak9gq+mjrj6C6BR9atmlA=");

foreach (EncodingInfo ei in Encoding.GetEncodings())
{
    Encoding e = ei.GetEncoding();
    string decodedString = e.GetString(data);
    Console.WriteLine($"{e.EncodingName}: {decodedString}");
}