.NET バイナリを難読化ツール (少なくとも文字列の難読化を有効にして) を介して実行し、ビルド プロセスの後半でこれを検証するためのいくつかの基本的なチェックを行います。static readonly string文字列を からにconst string変更すると、逆アセンブルされたコードを (出力を介して) 表示したときに、変更された文字列がプレーン テキストで表示されるようになったことに驚きましたildasm。
const string文字列の難読化に関して、との違いは何static readonly stringですか?
編集:例として、ここに小さなプログラムがあります:
class Program
{
private const string MyConstString = "MyConstString";
private static readonly string MyStaticReadonlyString = "MyStaticReadonlyString";
static void Main(string[] args)
{
string myLocalString = "myLocalString";
Console.WriteLine(MyConstString);
Console.WriteLine(MyStaticReadonlyString);
Console.WriteLine(myLocalString);
Console.WriteLine("Hit <ENTER> to exit");
Console.ReadLine();
}
}
.il コードを見ると、プレーン テキストの唯一の値はconst string. これは、次の 2 つの異なる難読化ツールに当てはまります。
.field private static literal string a = "MyConstString" // using Dotfuscator
.field private static literal string '[SOH]' = "MyConstString" // using RedGate SmartAssembly