title: Encrypt .net assemblies/Anti debug techniques
body: <p>I'm looking for a way to encrypt .net assemblies(exe, dll) or apply anti-debug techniques. I know that the assemblies don't contain native byte code but CIL Code and can be easily decompiled.<br> Honestly I have to say I am quite new to .NET. I come from a web-developer background and C# is just a hobby so I don't really need to encrypt my executables but I wondered how solutions like dotfuscator might work.<br>
  I also know that the files have to be decrypted in memory in order to execute them but this is the same with assemblies containing native code. <br>
  What I don't want is a discussion whether encrypting .NET executables is useful or not. I am just interested in the theoretical approach one can take to apply encryption or anti-debug techniques (control-flow-obfuscation for example).
  As you can see from the example and the related question below, my knowledge is far below ZERO. I am the typical application coder who is happy if the code compiles and runs but I'd like to dig deeper.</p>
  
  <pre><code>using System;
  namespace HelloWorld
  {
      class Hello 
      {
          static void Main() 
          {
              if(1 &lt; 2) 
              {
                  if(3 == 3)
                  {
                      if ("a" != "b")
                      {
                          if(0 != 1)
                          {
                              Console.WriteLine("Hello World!");
                          }
                      }
                  }
              }
              Console.ReadLine();
          }
      }
  }
  </code></pre>
  
  <p>Could the useless conditions be labeled as control-flow-obfuscation?<br>
  Please share your suggestions, any link that might be interesting or book recommendations.</p>