Constants Encryption Enterprise

Numeric literals in your code reveal magic numbers, buffer sizes, protocol values, and algorithm parameters. Demeanor replaces each numeric literal with an equivalent expression that produces the same result at runtime. The original numeric value never appears in the decompiled output, and the JIT folds the expression in Release builds so there is no measurable runtime cost.

Usage

CLIMSBuildDefault
(enabled by default at Enterprise)(enabled by default at Enterprise)On
--no-constants<DemeanorNoConstants>true</DemeanorNoConstants>Disable

Constants encryption is ON by default at the Enterprise tier. Set <DemeanorNoConstants>true</DemeanorNoConstants> in your .csproj to disable it for a specific build.

Before & After

YOUR CODE
private const int MaxTrialDays = 30;
private const int GracePeriodDays = 7;

if (key.Length != 25 || key[5] != '-')
    return false;

foreach (char c in key.Where(char.IsLetterOrDigit))
    checksum = (checksum * 31 + c) & 0x7FFFFFFF;

return checksum % 97 == 0;
AFTER OBFUSCATION
// 30 → arithmetic expression
if (days > -505527931 - -505527968)

// 25 → multiplication + addition
if (a.Length != -12946822 * -879980427 + 556600919)

// 31 → multiplication + addition
num = (num * (1327598100 * 806479407 + 1802874483) + item)

// 97 → bitwise arithmetic
return num % (0x2452FFEB ^ 0x2452FF8A) == 0;

Real ILSpy output. Every numeric literal — 30, 7, 25, 31, 97, even the 100 for the decimal division — is gone. The decompiled code shows arithmetic that produces the same result without revealing the original value.

When to Disable

  • Extreme assembly-size constraints — constants expand modestly. Only relevant for assemblies near the 4 GB code-section limit, which is vanishingly rare.
  • In practice, there is no reason to disable this option. It has no measurable runtime cost and significantly increases the effort required to understand your code.

Ready to protect your .NET code?

View Pricing All Options