We run our .NET binaries using obfuscator (with at least the obfuscation function turned on), and later during the build process, do some basic checks to verify this. I was surprised to notice that by changing the lines from static readonly string to const string , the changed lines were now visible in plain text when viewing disassembled code (via ildasm output).
As for string obfuscation, what is the difference between const string and static readonly string ?
EDIT: For example, here is a small program:
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(); } }
Looking at the .il code, the only value in text format for const string . This is true for two different obfuscation tools:
.field private static literal string a = "MyConstString"
source share