/

Constant Encryption

Protection ID: constants_advance or basic: constants_basic

This protection encodes and compresses the constants (numbers, strings and initializers) in the code.

With the ©Smart Native Protection System mode the constants are decrypted with the module verification sum, this system ensures the integrity of the applications.

Startup Enterprise


Parameters

Elements string : Determine what type of constants will be encoded. This option is only available in the Startup and Enterprise editions.

  • Strings default : Protect all the strings, constants and fields of your application, also those of the metadata.
  • Numeric: Protects all application integers.
  • Primitives: Protects all data of primitive types.
  • Arrays: Encrypts application arrays.

Rules configuration

  • shield.config.json
{
  "protections": {
    "constants_advance": {
      "elements": "strings|arrays|numeric" // string with the selected elements separated by a vertical bar
    }
  }
}

Modes

  • Basic constants_basic : Basically encrypts application strings to prevent them from being searched when decompiling the assembly.

  • Advanced constants_advance : Startup Protect the constants with the checksum of the method and its name. Ensures the integrity of the code, after this protection you will not be able to modify the code or rename the methods.

  • © Smart native protection system: Enterprise Protect the constants with the verification sum of the method and its name using native functions that prevent the constants from being debited or decryption methods invoked. Ensures the integrity of the code, after this protection you will not be able to modify the code or rename the methods.


Code example

  • Before:
var key = "https://www.bytehide.com";
string password = "admin";
Console.WriteLine($"key: {key}, password: {password}");
Console.ReadKey();
  • After:
string text = <Module>.get_Condition(VARFLAG_FREPLACEABLE[(94010 < 500724) ? 0 : 537936],unchecked(checked(unchecked(570830 - -870451) + ConcurrentDictionary__2.TargetedPatchingOptOutAttribute);
<Module>.init(text,(Convert.ToInt32( " 1000011100000110110 ", 2) | 250883 * 2) ^ Marshal.SizeOf(typeof(MoveBufferArea)));

string text2 = <Module>.get_Condition((int) array2[((62301 < 630141) ? -255426 : -270726) + (83010 | 172416)],(ConcurrentDictionary__2.add_ReflectionOnlyNamespaceResolve * checked((array[6] >>
(6 | 4)) - unchecked(833425 + -830673) * Convert.ToInt32( " 334 ", 8)));
<Module>.init(text2,((18665 % 7466 > Convert.ToInt32( " fffd0bb9 ", 16)) ? 1 : 0) == 0 / 2133));

Console.WriteLine($" key: {text}, password: {text2} ");
Console.ReadKey();

Exclusions

  • Exclude with attribute

Include this attribute in your source code:

[Obfuscation(Exclude = false, Feature = "-constants_advance")]
  • Exclude from the interface

You can exclude this protection from the methods or classes you want.


Compatibility

FrameworkCompatibilityComments
.NET Core
.NET Framework
.NET (up to 8 version)
.NET Standard
Xamarin IOS
Xamarin Android
Xamarin MacOs
WPF
Blazor
.NET Maui
Unity
ASP
Silverlight
VBa (Visual Basic) or C# (CSharp)
WinRT

Shield is compatible with all versions of .NET, it doesn't matter if you use .NET 2.0, .NET 4.7, .NET Core 2.1 or Xamarin.Forms 5.0, it will adapt automatically according to needs, you don't have to worry about this.

Previous
Constant Disintegration