It's only natural for programmers to try to protect their work using obfuscation techniques. Deliberate obfuscation makes the code difficult for others to understand and read, which makes it more cumbersome to insert malicious snippets into the original code to use it in cyber attacks.
There are various obfuscators out there that can be used to encrypt code. If you are a .NET developer, one of the alternatives you can opt for is DNGuard HVM Professional Edition.