SmartAssembly 6

Encoding strings

Managed software stores all the strings in one place and in a clear structure. This makes it easy to find the strings in a decompiled assembly. By following the references to these strings, it may be possible to understand the purpose of your code, even after obfuscation.

String encoding protects against this.

Using string encoding

To encode strings, in the Project Settings window, go to Strings Encoding or click the icon in the toolbar.

Select I want to hide important information by encoding all the strings in my software.

A const string cannot be encoded. You should use static readonly string instead.

 

Strings encoding options

The following strings encoding options are available: 

I want to use strings encoding with improved protection

Protects against assembly modification.

You cannot use this feature if you use another tool to modify your assembly after SmartAssembly.

You can't use this option with assemblies using any version of Silverlight, Windows Phone 7.x XNA, Xbox XNA, or Windows Phone 7.x, or with SQL CLR assemblies.

I want to compress and encrypt the encoded strings

Improves protection and reduces assembly size.

You can't use this option with assemblies using Xbox XNA, or with SQL CLR assemblies.

I want my application to cache strings when decoded

Enables strings to be loaded quickly.

You can use this option with all of the technologies supported by SmartAssembly.

The strings are automatically decoded, when needed, at runtime.

When string encoding is enabled, the colored bars under the toolbar icon and to the left of the feature options are green. If it is disabled, the bars are orange.

String encoding examples

The examples below show the effect of encoding three strings within an assembly:

Before string encoding:

"Fred.gate@hotmail.com"
"p@ssw0rd1"
"licensingUrl=http://licensing.red-gate.com/licensingactivation.asmx"

After string encoding:

"FNRFk1TTJZM016VTPQ==.bmV1dSBzcGVjaWZpZWQ9sbGVjdGlvbi4=L"

 

Using strings encoding with enums

Note that enums are normally obfuscated, but you would not want an obfuscated enum value to be displayed in your UI. SmartAssembly assumes that enum values which have Format, GetName, GetNames, Parse, or ToString called on them will be displayed to users, and so these enums are excluded from obfuscation automatically.

If your code uses enums in other ways, you can exclude all enums from obfuscation:

  1. Close SmartAssembly
  2. Use an XML editor to open the *.saproj file for your SmartAssembly project
  3. In the <Options> section, add the following element:
    <
    DoNotObfuscateAnyEnums/>
  4. Save the *.saproj file, and reopen the project in SmartAssembly.

Didn't find what you were looking for?