License-Bound Code Encryption
This example makes a protected feature cryptographically dependent on a valid license by combining two Babel technologies: MSIL Code Encryption encrypts the body of a sensitive method, and Babel Licensing stores the decryption password — itself encrypted — inside a signed, hardware-locked license. The Babel Virtual Machine asks the application for the password through a get password hook, which returns it only after the license validates. Removing or bypassing the license check is not enough: without a valid license there is no password, and without the password the encrypted code cannot run.
To use this example you need a site license for Babel Obfuscator (Ultimate, Server or Data Center editions) and Babel Licensing. The source code is available on GitHub:
git clone https://github.com/babelfornet/license-bound-encryption-console-example.gitThe sensitive method is marked so Babel keeps the encrypted body inside the assembly and asks for its password at runtime:
[Obfuscation(Feature = "msil encryption:internal=true;source=core;password=...")]
public static int Compute(int a, int b) { /* protected body */ }
[Obfuscation(Feature = "msil encryption get password")]
internal static string GetSourcePassword(string source)
{
// Validate the license and return the password only when it is valid.
}The code password never appears in clear in the shipped binary. It is written (encrypted with a
vendor secret) into a license field, and recovered at runtime only from a validly signed license
bound to the current machine. A companion LicenseGenerator project mints the license.
Valid license -> Compute(7, 5) = 147 (the encrypted method runs)
Missing / tampered -> Protected computation blocked (the BVM cannot decrypt the method)This is the pattern behind Babel’s own feature gating; see License-Bound Code Encryption in the Code Encryption manual for the full explanation, and Feature Based Licenses for a multi-feature variant.