在base64字符串中搜索的最佳方法是什么?

时间:2012-11-06 11:35:54

标签: visual-studio-2010 search base64 webtest performance-testing

我正在使用Visual Studio 2010,Web测试项目。 Web请求具有html主体的属性,当将其保存到文件系统时,该属性将编码为base64。

问题是当我尝试在解决方案中搜索html正文(在base64中编码)的内容时。普通搜索不会在这些字符串中搜索。搜索的最佳方式是什么,最好使用VS2010 IDE? (宏,扩展,一些外部工具......)

我想搜索的xml文件示例:

<StringHttpBody>tAC8AWQAiAA0ACgB9AA==</StringHttpBody>

我希望得到存在确认 - 这个base64字符串是否包含一些编码字

1 个答案:

答案 0 :(得分:2)

你的问题不是很清楚,但如果你在谈论用编码的字符串进行搜索,我认为你没有选择,只能解码然后搜索。但这并不复杂:

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
  ...

}

<强>更新 根据您更新的问题,如果您希望它直接从VS2010 IDE运行。 基于上述逻辑创建一个简单的程序,该命令从命令行接收2个字符串。然后使用以下命令将该程序添加为外部工具:

Tools -> External Tools
相关问题