Frage

I am using Visual Studio 2010, Web test project. A web request has a property of html body which is encoded to base64 when it is saved to file system.

The problem is when I am trying to search for content of html body (that encoded in base64) in solution. Normal search won't search inside these strings. What is the best way to search, preferably using the VS2010 IDE? (macro, extension, some external tool...)

Example of xml file that I would like to search ins:

<StringHttpBody>tAC8AWQAiAA0ACgB9AA==</StringHttpBody>

I expect to get existence confirmation - does this base64 string contains some encoded word

War es hilfreich?

Lösung

You question isn't very clear, but if you're talking about searching in an encoded string, I don't think you have a choice but to decode it and then search. It isn't that complicated though:

public static void SearchInBase64(string encodedData, string searchText)
{
  byte[] encodedDataAsBytes
      = System.Convert.FromBase64String(encodedData);

  string decodedValue =
     System.Text.ASCIIEncoding.ASCII.GetString(encodedDataAsBytes);

  // Perform search on decodedValue
  ...

}

Update: Based on your updated question, if you want it to run directly from the VS2010 IDE. Create a simple program based on the above logic which receives the 2 strings from the command line. Then add that program as an external tool using:

Tools -> External Tools
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top