Search code examples
c#jsonencryptionbase64streamreader

Troubles read encrypted string which get from Web Request using StreamReader


So basically I want to get json string from specific url, and this json string is encrypted become a .txt file. All I want to do is get the encrypted string and decrypt it inside my application.

Here is my HttpWebRequest code to get the response string:

public string GetResponse(url)
{   
    string responseString = "";
    HttpWebRequest webRequest = HttpWebRequest.Create(url) as HttpWebRequest;

    HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
    using (StreamReader reader = new StreamReader(response.GetResponseStream()))
    {
        responseString = reader.ReadToEnd();
    }

    return responseString;
}

But what I get from the response is actually an unreadable string (only "O")

I already try to convert it to byte array before convert it to Base64 string, but still, the response string is not right.

Thanks for the help.


Solution

  • Unfortunately, i didnt realize that the response string actually includes added character "/0" which i have to remove it first, then i able to decrypt the string.

    Thank you very much.