Skip to content

Examples ​

Choose a language or build tool. Each guide includes source files, configuration, commands for the original and generated program, and the language's external names to preserve.

CLI examples outside Node.js projects use one global Codefend installation, so they do not need npm project files. Node.js, TypeScript, and bundler examples keep their tooling local to the project. See installation to choose the setup. The configurations show only necessary settings; omitted options use Codefend's defaults. codefend --obfuscate already runs configuration checking, so a separate --check command is optional.

Each guide shows expected obfuscated source directly after the input code and includes a section on adding Codefend to an existing build, test, or CI workflow. CLI examples require Codefend 3.3.0 or later and use the recommended startWithMAndUnderscore preset to select explicit m_ names without repeating a custom regex. The bundler examples require plugin version 3.3.0 or later and explicitly select the same preset; omitted plugin parser settings retain codeOnly.

Languages ​

LanguageExample focus
JavaScript (Node.js)Execute a CommonJS program before and after obfuscation.
TypeScriptTransform source, compile it, and execute explicit CommonJS output.
PythonRename application functions and locals while preserving Python entry-point behavior.
C#Preserve the program entry point and keep .NET build artifacts outside the input tree.
JavaPreserve the public class name, source filename, and main method.
CRename private helpers and variables while preserving main and standard-library calls.
C++Transform a small native program while keeping compiler and library contracts stable.
GoPreserve package/main entry points and keep generated helper names unexported.
RustRename a private helper without changing standard-library macros or public names.
PHPPreserve variable sigils and PHP APIs while renaming application names.
RubyUse lowercase replacements to preserve local-variable and method naming rules.
KotlinPreserve main and keep JAR build products outside processed source.
SwiftKeep argument-label and entry-point behavior explicit.
DartPreserve main and platform APIs in a small command-line program.
RRun a calculation while preserving built-in functions and external data names.
LuaRename local functions and variables without changing host or standard-library names.
SQL (SQLite)Rename internal query aliases while keeping the public result column stable.
BashPreserve shell built-ins and external environment/command contracts.
PowerShellPreserve cmdlets and external parameter names while renaming private script names.
HTML and CSSKeep an application-owned class consistent across markup and stylesheet files.

Codefend's configurable text rules can apply across these languages; they do not provide a language-aware parser or universal compatibility guarantee. These examples use small, source-only inputs and explicit naming conventions. Compile or run both versions in your own toolchain before extending the pattern to a larger project.

The automated docs checks verify each language fixture's actual Codefend transformation. They execute the Node.js and SQL examples and check HTML/CSS references. Other language compilation and runtime checks depend on installed toolchains; see the commands in each guide.

Arduino ​

Obfuscate an Arduino sketch while preserving its sketch-folder/primary-file relationship, framework callbacks, and library APIs. Both example versions were compiled for the Uno target.

Bundlers ​

Build toolGuide
ViteUse the dedicated Vite plugin, which runs automatically during production builds.
esbuildBuild and execute two JavaScript modules with esbuild-plugin-codefend.
RollupBundle a two-module JavaScript example.
WebpackProcess a production JavaScript bundle with the official plugin.

Read how it works, naming conventions, and troubleshooting for shared configuration and current limitations.

Examples are maintained in this documentation site. Use the language and bundler guides above for complete source code, configuration, and build commands.