Custom String Encryption

Custom string encryption enables users to formulate their own methods for encrypting and decrypting strings, allowing for personalized obfuscation of strings. To leverage custom string encryption, users are required to define two specific methods within the target assembly: EncryptString and DecryptString. Both methods must have identical signatures, accepting a string as a parameter and returning a string, which represents either the encrypted or decrypted string, respectively. By establishing these methods, users have the flexibility to implement any custom encryption algorithm of their choice to encrypt strings in their code, granting enhanced adaptability and command over the obfuscation process.

/// <summary>
/// Encrypt a string.
/// </summary>
/// <param name="text">The string to encrypt.</param>
/// <returns>The encrypted string.</returns>
[Obfuscation(Feature = "string encryption encrypt method")]
internal static string EncryptString(string text)
{
   // Encrypt the text string and return the encrypted string object.
   return ...;
}
/// <summary>
/// Decrypt an encrypted string.
/// </summary>
/// <param name="text">The encrypted string.</param>
/// <returns>The decrypted string.</returns>
[Obfuscation(Feature = "string encryption decrypt method")]
internal static string DecryptString(string text)
{
   // Decrypt the text string and return the decrypted string object.
   return ...;
}

The EncryptString and DecryptString methods are addressed by the Obfuscation attribute with a proper Feature string, which allows Babel to identify the code entry points for encrypting and decrypting strings.

Once you have defined the EncryptString and DecryptString methods and addressed them with the proper Obfuscation attribute, you can then enable custom string encryption with Babel.

To encrypt or decrypt strings using the methods provided, you have several options based on your project setup and preferences. These include configuring the Babel UI, utilizing the command line, or implementing an MSBuild task.

User Interface

To utilize Custom String Encryption through the Babel Obfuscator User Interface (UI), navigate to Settings within the Babel UI, you are required to enable the Encrypt Strings check box and select the custom option.

Additionally, for further customization and extension of the encryption capabilities, Babel supports the integration of external plugins. This feature allows for a more flexible and robust encryption mechanism, tailored to the specific needs and security requirements of your application.

Command Line

To enable Babel custom string encryption using the command line, you can enter the command:

babel myapp.exe --strings custom

MSBuild Babel Task

If you are using the Babel task, you can enable custom string encryption by adding the following to your project file:

<PropertyGroup>
  <StringEncryption>custom</StringEncryption>
</PropertyGroup>

<Babel StringEncryption="$(StringEncryption)" ... />

In addition, users can also implement custom string encryption using external plugins (see Babel Obfuscator Plugins).

Last updated